Add email qq and signal
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user