-
Notifications
You must be signed in to change notification settings - Fork 355
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
[Bug]: go-cqhttp上报消息格式为array时发送任意消息报错TypeError: expected string or bytes-like object #436
Comments
麻烦参考 #402 开启调试模式之后贴上详细输出信息;你这是使用插件发送消息时的报错吗? |
手动安装,没有安装和使用任何其他插件,上面的内容其实就是完整的报错信息。
|
发了什么内容给机器人? |
发送任何文字都会导致报错。无论是!开头的指令或是纯中文/英文文本 |
提供一下gocq的版本以及输出 |
请注意留意消息格式,这里go-cqhttp使用的是array格式的上报消息,示例如下:
和string格式的上报消息不同,需要对消息格式做处理。
|
报错导致的原因与go-cqhttp版本并无太大关系,当我使用的go-cqhttp版本是v1.0.0-rc5,目前几乎所有版本均支持string或array两种消息格式,设置方法为编辑
重启go-cqhttp和QChatGPT后,给机器人发送任意消息,即可复现上述bug。 |
这应该是依赖库nakuru的兼容性问题 |
已在由我们维护的nakuru-project 分支仓库中跟踪此问题 idoknow/nakuru-project-idk#2 ,目前请先尝试设置消息格式为纯文本,或尝试使用mirai |
部署方式
手动部署
登录框架
go-cqhttp
系统环境
Ubuntu 20.04 LTS
Python环境
Python 3.10.6
异常情况
运行python main.py并确认连接上go-cqhttp完成登录后,发送任意消息时均导致报错并卡死。
其中go-cqhttp的上报消息格式是
post-format: array
,当修改为post-format: string
后工作正常。请考虑支持使用array格式的消息
报错信息
[2023-04-25 11:05:51.524] base_events.py (1744) - [ERROR] : Task exception was never retrieved
future: <Task finished name='Task-2' coro=<CQHTTP.ws_event() done, defined at /home/user/.local/lib/python3.10/site-packages/nakuru/application.py:56> exception=TypeError('expected string or bytes-like object')>
Traceback (most recent call last):
File "/home/user/.local/lib/python3.10/site-packages/nakuru/application.py", line 69, in ws_event
received_data = MessageTypes[received_data["message_type"]].parse_obj(received_data)
File "pydantic/main.py", line 526, in pydantic.main.BaseModel.parse_obj
File "/home/user/.local/lib/python3.10/site-packages/nakuru/event/models.py", line 33, in init
message = parser.parseChain(message)
File "/home/user/.local/lib/python3.10/site-packages/nakuru/misc.py", line 104, in parseChain
text = self.plainToCQ(text)
File "/home/user/.local/lib/python3.10/site-packages/nakuru/misc.py", line 72, in plainToCQ
cqIndex = self.__getCQIndex(text)
File "/home/user/.local/lib/python3.10/site-packages/nakuru/misc.py", line 50, in __getCQIndex
for m in re.compile("([CQ:(.+?)])").finditer(text):
TypeError: expected string or bytes-like object
The text was updated successfully, but these errors were encountered: