Skip to content

Commit

Permalink
fix: 修复GUILD_DELETE事件监听不到的问题 (#59)
Browse files Browse the repository at this point in the history
* fix: 修复GUILD_DELETE事件监听不到的问题

* fix: 修复重连会报错的问题

Co-authored-by: jichendai <jichendai@tencent.com>
  • Loading branch information
DaiJiChen and jichendai committed May 8, 2022
1 parent 6a676dc commit 843f285
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions qqbot/core/network/ws/ws_handler.py
Expand Up @@ -22,9 +22,17 @@ class DefaultHandler:

@classmethod
def get_handler_by_type(cls, event_type: str):
if event_type in (WsEvent.EventGuildCreate, WsEvent.EventGuildUpdate, WsEvent.EventGuildUpdate):
if event_type in (
WsEvent.EventGuildCreate,
WsEvent.EventGuildUpdate,
WsEvent.EventGuildDelete
):
return cls.guild
elif event_type in (WsEvent.EventChannelCreate, WsEvent.EventChannelUpdate, WsEvent.EventChannelDelete):
elif event_type in (
WsEvent.EventChannelCreate,
WsEvent.EventChannelUpdate,
WsEvent.EventChannelDelete
):
return cls.channel
elif event_type in (
WsEvent.EventGuildMemberAdd,
Expand Down
2 changes: 1 addition & 1 deletion qqbot/core/network/ws_async/ws_async_handler.py
Expand Up @@ -18,7 +18,7 @@


async def parse_and_handle(ws_event, data):
event_id = ws_event["id"]
event_id = ws_event["id"] if "id" in ws_event.keys() else ""
event_type = ws_event["t"]
context = WsContext(event_type, event_id)
callback = DefaultHandler.get_handler_by_type(event_type)
Expand Down
2 changes: 1 addition & 1 deletion qqbot/core/network/ws_sync/ws_event_handler.py
Expand Up @@ -18,7 +18,7 @@


def parse_and_handle(ws_event, data):
event_id = ws_event["id"]
event_id = ws_event["id"] if "id" in ws_event.keys() else ""
event_type = ws_event["t"]
context = WsContext(event_type, event_id)
callback = DefaultHandler.get_handler_by_type(event_type)
Expand Down

0 comments on commit 843f285

Please sign in to comment.