console_im_service.py
973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Console IM service — prints hook output instead of sending to real IM."""
import json
from typing import Dict, Any, Optional
class ConsoleIMService:
"""IMService replacement that prints to console for testing."""
def __init__(self):
self._client = None
async def send_message(
self,
bot_id: str,
content: str,
contact_id: str,
at_list: str = "",
) -> Dict[str, Any]:
payload = {
"bot_id": bot_id,
"content": content,
"contact_id": contact_id,
"msg_type": "text",
}
if at_list:
payload["at_list"] = at_list
print("\n" + "=" * 50)
print(" [Hook: post_reply] → 计划发送到 IM")
print("=" * 50)
print(json.dumps(payload, ensure_ascii=False, indent=2))
print("=" * 50 + "\n")
return {"status": "printed", "bot_id": bot_id}
async def close(self):
pass