Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wechaty群聊@消息没有反馈 #501

Closed
B1gM8c opened this issue Mar 18, 2023 · 4 comments
Closed

Wechaty群聊@消息没有反馈 #501

B1gM8c opened this issue Mar 18, 2023 · 4 comments

Comments

@B1gM8c
Copy link
Contributor

B1gM8c commented Mar 18, 2023

前置确认

  1. 网络能够访问openai接口
  2. python 已安装:版本在 3.7 ~ 3.10 之间,依赖已安装
  3. 在已有 issue 中未搜索到类似问题
  4. FAQS 中无类似问题

问题描述

简要说明、截图、复现步骤等,也可以是需求或想法

群里配置文件已经设置全部群都接收了,并且这里也可以看到能收到群消息,但是过滤@后的内容似乎出现了错误,导致没有获取到内容,无法回复。如果使用关键词在群里是可以得到回复的,@他是不行的,私聊测试是正常的

终端日志 (如有报错)

2023-03-18 18:04:39,795 - Contact - INFO - load contact <Contact <wxid_vdvodsc2drgw22> <XXXX>>
2023-03-18 18:04:39,799 - Wechaty - INFO - receive message <Message#message_type_text[🗣 Contact <wxid_vdvodsc2drgw22> <XXXX>@👥 Room <25730332097@chatroom - XXXXXX>]       @XX 你好>
2023-03-18 18:04:39,800 - Message - INFO - Message mention_list
Exception in callback AsyncIOEventEmitter._emit_run.<locals>.callback(<Task finishe...ertionError()>) at /usr/local/lib/python3.7/site-packages/pyee/asyncio.py:65
handle: <Handle AsyncIOEventEmitter._emit_run.<locals>.callback(<Task finishe...ertionError()>) at /usr/local/lib/python3.7/site-packages/pyee/asyncio.py:65>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.7/site-packages/pyee/asyncio.py", line 71, in callback
    self.emit("error", exc)
  File "/usr/local/lib/python3.7/site-packages/wechaty/wechaty.py", line 332, in emit
    return super().emit(event, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pyee/base.py", line 179, in emit
    self._emit_handle_potential_error(event, args[0] if args else None)
  File "/usr/local/lib/python3.7/site-packages/pyee/base.py", line 139, in _emit_handle_potential_error
    raise error
  File "/www/wwwroot/wechat/XiaoQiu/channel/wechat/wechaty_channel.py", line 68, in on_message
    mention_content = await msg.mention_text()  # 返回过滤掉@name后的消息
  File "/usr/local/lib/python3.7/site-packages/wechaty/user/message.py", line 480, in mention_text
    mention_list = await self.mention_list()
  File "/usr/local/lib/python3.7/site-packages/wechaty/user/message.py", line 462, in mention_list
    for contact_id in self.payload.mention_ids]
  File "/usr/local/lib/python3.7/site-packages/wechaty/user/message.py", line 462, in <listcomp>
    for contact_id in self.payload.mention_ids]
  File "/usr/local/lib/python3.7/site-packages/wechaty/user/message.py", line 456, in id_to_contact
    await contact.ready()
  File "/usr/local/lib/python3.7/site-packages/wechaty/user/contact.py", line 286, in ready
    self.contact_id)
  File "/usr/local/lib/python3.7/site-packages/wechaty_puppet_service/puppet.py", line 550, in contact_payload
    response = await self.puppet_stub.contact_payload(id=contact_id)
  File "/usr/local/lib/python3.7/site-packages/wechaty_grpc/wechaty/__init__.py", line 120, in contact_payload
    "/wechaty.Puppet/ContactPayload", request, puppet.ContactPayloadResponse
  File "/usr/local/lib/python3.7/site-packages/betterproto/__init__.py", line 1125, in _unary_unary
    assert response is not None
AssertionError

环境

  • 操作系统类型 (Mac/Windows/Linux):Linux
  • Python版本 ( 执行 python3 -V ):3.7.9
  • pip版本 ( 依赖问题此项必填,执行 pip3 -V):pip3.7
@B1gM8c B1gM8c changed the title Wechaty群聊没有反馈 Wechaty群聊@消息没有反馈 Mar 18, 2023
@B1gM8c
Copy link
Contributor Author

B1gM8c commented Mar 18, 2023

问了下chatgpt,好像是wechaty的问题

根据报错信息,可以看到是在 on_message 函数中调用 msg.mention_text() 函数时发生了错误。具体来说,msg.mention_text() 函数内部调用了其他函数 mention_list 和 id_to_contact,但在执行这些函数时出现了问题。

更具体地说,问题似乎出现在了 contact.ready() 函数调用上。根据报错信息中的最后几行代码,可以看到该函数返回了一个 AssertionError。这通常表示某个断言语句未能得到满足,即出现了一些预料之外的错误情况。

要修复这个问题,首先需要了解这段代码的上下文和目的。根据报错信息中的代码行号和函数名,这段代码可能是使用了一个名为 Wechaty 的 Python 库实现的微信机器人。在这个机器人中,msg.mention_text() 函数似乎是用于获取群聊中被 @ 到的消息内容,并且在这个过程中需要获取消息中被 @ 的用户的相关信息。

如果您正在使用 Wechaty 库,请检查相关的配置和环境是否正确。此外,还可以尝试更新 Wechaty 库到最新版本,看看是否有已知的 bug 已被修复。如果问题仍然存在,您可以尝试在 Wechaty 的 GitHub 仓库中提出问题,寻求开发者的帮助。

@B1gM8c
Copy link
Contributor Author

B1gM8c commented Mar 18, 2023

好像确实是wechaty的问题,我看了他们的issues里也有
wechaty/python-wechaty#389

@aardwolf109
Copy link

@wj-Mcat
Copy link

wj-Mcat commented Mar 25, 2023

I have gaven the comemnt and suggested code, please help yourself. Good luck to you.

wechaty/python-wechaty#389 (comment)

@lanvent lanvent closed this as completed Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants