| 12345678910111213141516171819202122 |
- import logging
- log = logging.getLogger(__name__)
- class AgentNotifier:
- """Agent 通知接口基类。
- 当 pending.json 有新消息时,Client 会调用 notify()。
- 每个 Agent 可以继承此类实现自己的通知方式。
- """
- async def notify(self, count: int, from_contacts: list[str]):
- raise NotImplementedError
- class ConsoleNotifier(AgentNotifier):
- """默认实现:打印到控制台。"""
- async def notify(self, count: int, from_contacts: list[str]):
- sources = ", ".join(from_contacts)
- log.info(f"[IM 通知] 你有 {count} 条新消息,来自: {sources}")
|