-
Notifications
You must be signed in to change notification settings - Fork 379
Description
检查项
- 我确认此问题在所有分支的最新版本中依旧存在
- 我确认在 Issues 列表中并无其他人已经提出过与此问题相同或相似的问题
- 我使用了 Docker
使用的分支
main
具体版本号
0.10.3
遇到的问题
从旧版本更新到10.3版本时,运行会报错。无论直接旧版本git pull更新,还是删除重装都一样。
报错信息
10-01 17:05:51 [主程序] 主程序发生异常: 'MessageServer' object has no attribute 'register_custom_message_handler' Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\QQbot\MaiM-with-u\MaiBot\bot.py", line 208, in
loop.run_until_complete(main_system.initialize())
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python313\Lib\asyncio\base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "C:\Users\Administrator\Desktop\QQbot\MaiM-with-u\MaiBot\src\main.py", line 44, in initialize
await asyncio.gather(self._init_components())
File "C:\Users\Administrator\Desktop\QQbot\MaiM-with-u\MaiBot\src\main.py", line 107, in _init_components
self.app.register_custom_message_handler("message_id_echo", chat_bot.echo_message_process)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'MessageServer' object has no attribute 'register_custom_message_handler'. Did you mean: 'register_message_handler'?
10-01 17:05:51 [主程序] 事件循环已关闭
10-01 17:05:51 [logger] 正在关闭日志系统...
如何重现此问题?
安装后使用cmd运行uv run python .\bot.py命令。
可能造成问题的原因
经询问G指导获取:在新版本的MaiBot中,开发者将一个名为 register_custom_message_handler 的函数,改名为 register_message_handler(去掉了_custom)。但是,在 main.py 这个主程序文件里,调用这个函数的代码没有同步更新,还在使用旧的名字,所以程序在启动时就找不到这个函数,导致了崩溃。
系统环境
windows server 2022
Python 版本
python 3.11
补充信息
将src\main.py中的107行的
self.app.register_custom_message_handler("message_id_echo", chat_bot.echo_message_process)
改成:
self.app.register_message_handler(chat_bot.echo_message_process)
就可以正常运行了。
Metadata
Metadata
Assignees
Labels
Type
Projects
Status