Add email qq and signal

This commit is contained in:
MuXinCG
2026-02-18 22:44:34 +08:00
parent 98e133564f
commit db6e309fdd
3 changed files with 39 additions and 43 deletions
+11 -11
View File
@@ -86,6 +86,17 @@ class EmailChannel(Channel, PollingMixin):
logger.info(f"Email channel started (IMAP: {cfg.imap_host}, poll {cfg.poll_interval}s)")
await self._start_polling()
async def _cleanup(self) -> None:
await self._stop_polling()
if self._imap:
try:
self._imap.close()
self._imap.logout()
except Exception:
pass
self._imap = None
logger.info("Email channel stopped")
def _connect_imap(self) -> None:
cfg = self.config
try:
@@ -353,14 +364,3 @@ class EmailChannel(Channel, PollingMixin):
except Exception as e:
logger.error(f"SMTP attachment send failed: from={from_addr} to={to} error={e}")
raise RuntimeError(f"SMTP attachment: {e}")
async def _cleanup(self) -> None:
await self._stop_polling()
if self._imap:
try:
self._imap.close()
self._imap.logout()
except Exception:
pass
self._imap = None
logger.info("Email channel stopped")
+11 -13
View File
@@ -90,6 +90,17 @@ class QQChannel(Channel):
logger.error(f"QQ auth failed: {e}")
self._running = False
async def _cleanup(self) -> None:
self._running = False
if self._bot_task:
self._bot_task.cancel()
try:
await self._bot_task
except asyncio.CancelledError:
pass
self._client = None
logger.info("QQ channel stopped")
# ── Incoming ──────────────────────────────────────────────────
async def _on_msg(self, message, msg_type: str) -> None:
@@ -243,16 +254,3 @@ class QQChannel(Channel):
if caption:
await self._send_chunk(chat_id, caption, caption, None, metadata or {})
return True
# ── Cleanup ───────────────────────────────────────────────────
async def _cleanup(self) -> None:
self._running = False
if self._bot_task:
self._bot_task.cancel()
try:
await self._bot_task
except asyncio.CancelledError:
pass
self._client = None
logger.info("QQ channel stopped")
+17 -19
View File
@@ -61,6 +61,23 @@ class SignalChannel(Channel):
# (start() must return so that run() can iterate receive())
self._listen_task = asyncio.create_task(self._listen_loop())
async def _cleanup(self) -> None:
if hasattr(self, "_listen_task") and self._listen_task:
self._listen_task.cancel()
self._listen_task = None
if self._writer:
self._writer.close()
try:
await self._writer.wait_closed()
except Exception:
pass
self._writer = None
self._reader = None
if self._daemon_proc:
self._daemon_proc.terminate()
self._daemon_proc = None
logger.info("Signal channel stopped")
async def _ensure_daemon(self) -> None:
"""Start signal-cli daemon if not already running."""
try:
@@ -404,22 +421,3 @@ class SignalChannel(Channel):
await self._rpc_call("send", params)
return True
# ── Cleanup ───────────────────────────────────────────────────
async def _cleanup(self) -> None:
if hasattr(self, "_listen_task") and self._listen_task:
self._listen_task.cancel()
self._listen_task = None
if self._writer:
self._writer.close()
try:
await self._writer.wait_closed()
except Exception:
pass
self._writer = None
self._reader = None
if self._daemon_proc:
self._daemon_proc.terminate()
self._daemon_proc = None
logger.info("Signal channel stopped")