mirror of
https://github.com/ylytdeng/wechat-decrypt.git
synced 2026-11-06 02:56:53 +08:00
feat(mcp): get_chat_history/get_chat_images 头部暴露 chatroom ID (#142)
同名前缀的群 (如 18福特Fusion_211 有 3 个租期群) 传显示名给 decode_image 会 resolve_username() 匹配错群 (通常是不含目标 local_id 的旧群). 修复: get_chat_history / get_chat_images 头部输出已解析的内部 username: - 群聊: [群聊, id=xxx@chatroom] - 单聊 (username != display_name 时): [id=wxid_xxx] 下游可直接拿 ID 回传给任意 MCP 工具的 chat_name 参数, resolve_username() 已识别 @chatroom / wxid_ 格式直接透传, 避开模糊匹配.
This commit is contained in:
1 parent
656d06a527
commit
ab08c83d41
1 file changed
+5
-2
+5
-2
@@ -2150,7 +2150,9 @@ def get_chat_history(chat_name: str, limit: int = 50, offset: int = 0, start_tim
|
||||
|
||||
header = f"{ctx['display_name']} 的消息记录(返回 {len(lines)} 条,offset={offset}, limit={limit})"
|
||||
if ctx['is_group']:
|
||||
header += " [群聊]"
|
||||
header += f" [群聊, id={ctx['username']}]"
|
||||
elif ctx['username'] != ctx['display_name']:
|
||||
header += f" [id={ctx['username']}]"
|
||||
if start_time or end_time:
|
||||
header += f"\n时间范围: {start_time or '最早'} ~ {end_time or '最新'}"
|
||||
if msg_types:
|
||||
@@ -3499,7 +3501,8 @@ def get_chat_images(chat_name: str, limit: int = 20, offset: int = 0, start_time
|
||||
line += " (无资源信息)"
|
||||
lines.append(line)
|
||||
|
||||
header = f"{display_name} 的 {len(lines)} 张图片(offset={offset}, limit={limit})"
|
||||
id_tag = f", id={username}" if username != display_name else ""
|
||||
header = f"{display_name} 的 {len(lines)} 张图片(offset={offset}, limit={limit}{id_tag})"
|
||||
if start_time or end_time:
|
||||
header += f"\n时间范围: {start_time or '最早'} ~ {end_time or '最新'}"
|
||||
return header + ":\n\n" + "\n".join(lines) + _pagination_hint(len(lines), limit, offset)
|
||||
|
||||
Reference in new issue
Block a user