Tian-que / nonebot-adapter-kaiheila

Kaiheila adapter for nonebot2
MIT License
27 stars 10 forks source link

v0.3.2版本机器人接收频道信息时报错:AttributeError: 'Config' object has no attribute 'ignore_events' #59

Closed HOursH closed 2 months ago

HOursH commented 3 months ago

当有用户在频道发消息的时候就会报错(私聊机器人发消息也一样): 03-12 21:26:29 [INFO] nonebot | Kaiheila | Bot 25113xxxxxx connected 03-12 21:26:30 [ERROR] nonebot | Kaiheila | Failed to parse event. Raw: {'s': 0, 'd': {'channel_type': 'GROUP', 'type': 9, 'target_id': '371118850xxxxx', 'author_id': '3640xxxxxx', 'content': '1', 'extra': {'type': 9, 'code': '', 'guild_id': '851537094xxxxxxx', 'guild_type': 0, 'channel_name': '文字频道', 'author': {'id': '3640xxxxxx', 'username': 'OP', 'identify_num': '0001', 'online': False, 'os': 'Websocket', 'status': 1, 'avatar': 'https://img.kookapp.cn/avatars/2022-06/2FsZxbg95Q02u02u.gif?x-oss-process=style/icon', 'vip_avatar': 'https://img.kookapp.cn/avatars/2022-06/2FsZxbg95Q02u02u.gif?x-oss-process=image/format,jpg', 'banner': '', 'nickname': 'OP', 'roles': [], 'is_vip': False, 'vip_amp': False, 'bot': False, 'nameplate': [], 'decorations_id_map': None, 'is_sys': False}, 'visible_only': None, 'mention': [], 'mention_all': False, 'mention_roles': [], 'mention_here': False, 'nav_channels': [], 'kmarkdown': {'raw_content': '1', 'mention_part': [], 'mention_role_part': [], 'channel_part': [], 'spl': []}, 'emoji': [], 'last_msg_content': 'OP:1', 'send_msg_device': 1, 'content': '1'}, 'msg_id': 'aa6d0df5-ed8c-42b5-9117-b3b15018ea75', 'msg_timestamp': 1710249999861, 'nonce': 'KftuWGIaU7ERHDI3Vu2UMbDD', 'from_type': 1, 'self_id': '25113xxxx', 'group_id': '371118850xxxxxx9', 'time': 1710249999861, 'user_id': '36408xxxxx', 'post_type': 'message', 'sub_type': 'kmarkdown', 'message_type': 'group', 'event': {'type': 9, 'code': '', 'guild_id': '851537094xxxxxx', 'guild_type': 0, 'channel_name': '文字频道', 'author': {'id': '3640xxxxx', 'username': 'OP', 'identify_num': '0001', 'online': False, 'os': 'Websocket', 'status': 1, 'avatar': 'https://img.kookapp.cn/avatars/2022-06/2FsZxbg95Q02u02u.gif?x-oss-process=style/icon', 'vip_avatar': 'https://img.kookapp.cn/avatars/2022-06/2FsZxbg95Q02u02u.gif?x-oss-process=image/format,jpg', 'banner': '', 'nickname': 'OP', 'roles': [], 'is_vip': False, 'vip_amp': False, 'bot': False, 'nameplate': [], 'decorations_id_map': None, 'is_sys': False}, 'visible_only': None, 'mention': [], 'mention_all': False, 'mention_roles': [], 'mention_here': False, 'nav_channels': [], 'kmarkdown': {'raw_content': '1', 'mention_part': [], 'mention_role_part': [], 'channel_part': [], 'spl': []}, 'emoji': [], 'last_msg_content': 'OP:1', 'send_msg_device': 1, 'content': '1'}, 'message_id': 'aa6d0df5-ed8c-42b5-9117-b3b15018ea75'}, 'extra': {'verifyToken': '1Brv4EerIfshGpJS', 'encryptKey': '', 'callbackUrl': ''}, 'sn': 1}

Traceback (most recent call last): File "C:\Users\Admin\Desktop\mcl\test\bot_3.py", line 1040, in nonebot.run() File "M:\python3.11\Lib\site-packages\nonebot__init__.py", line 334, in run get_driver().run(*args, *kwargs) File "M:\python3.11\Lib\site-packages\nonebot\drivers\none.py", line 56, in run loop.run_until_complete(self._serve()) File "M:\python3.11\Lib\asyncio\base_events.py", line 640, in run_until_complete self.run_forever() File "M:\python3.11\Lib\asyncio\windows_events.py", line 321, in run_forever super().run_forever() File "M:\python3.11\Lib\asyncio\base_events.py", line 607, in run_forever self._run_once() File "M:\python3.11\Lib\asyncio\base_events.py", line 1922, in _run_once handle._run() File "M:\python3.11\Lib\asyncio\events.py", line 80, in _run self._context.run(self._callback, self._args) File "M:\python3.11\Lib\site-packages\nonebot\adapters\kaiheila\adapter.py", line 261, in _forward_ws event = self.json_to_event(

File "M:\python3.11\Lib\site-packages\nonebot\adapters\kaiheila\adapter.py", line 450, in json_to_event if kaiheila_config.ignore_events and event_name.startswith(kaiheila_config.ignore_events): AttributeError: 'Config' object has no attribute 'ignore_events'

Tian-que commented 3 months ago

可能是由于Config没有写默认值,尝试配置

kaiheila_ignore_events = []

是否还会复现

HOursH commented 3 months ago

可能是由于Config没有写默认值,尝试配置

kaiheila_ignore_events = []

是否还会复现

请问是在.env文件内写入:kaiheila_ignore_events = []或者kaiheila_ignore_events = ["notice.guild_member_online"]对吗? 如果是的话,无效: kaiheila_bots =[{"token": "xxxx"}] kaiheila_ignore_events = [] kaiheila_ignore_other_bots = True

Tian-que commented 3 months ago

已修复,请使用 v0.3.3