Skip to content

Commit

Permalink
🐛 fix cqhttp event session id mismatch for group
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyongyu committed May 29, 2021
1 parent f609a9f commit 57cf8e9
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/nonebot-adapter-cqhttp/nonebot/adapters/cqhttp/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def get_user_id(self) -> str:

@overrides(NoticeEvent)
def get_session_id(self) -> str:
return str(self.user_id)
return f"group_{self.group_id}_{self.user_id}"


class GroupAdminNoticeEvent(NoticeEvent):
Expand All @@ -253,7 +253,7 @@ def get_user_id(self) -> str:

@overrides(NoticeEvent)
def get_session_id(self) -> str:
return str(self.user_id)
return f"group_{self.group_id}_{self.user_id}"


class GroupDecreaseNoticeEvent(NoticeEvent):
Expand All @@ -275,7 +275,7 @@ def get_user_id(self) -> str:

@overrides(NoticeEvent)
def get_session_id(self) -> str:
return str(self.user_id)
return f"group_{self.group_id}_{self.user_id}"


class GroupIncreaseNoticeEvent(NoticeEvent):
Expand All @@ -297,7 +297,7 @@ def get_user_id(self) -> str:

@overrides(NoticeEvent)
def get_session_id(self) -> str:
return str(self.user_id)
return f"group_{self.group_id}_{self.user_id}"


class GroupBanNoticeEvent(NoticeEvent):
Expand All @@ -320,7 +320,7 @@ def get_user_id(self) -> str:

@overrides(NoticeEvent)
def get_session_id(self) -> str:
return str(self.user_id)
return f"group_{self.group_id}_{self.user_id}"


class FriendAddNoticeEvent(NoticeEvent):
Expand Down Expand Up @@ -357,7 +357,7 @@ def get_user_id(self) -> str:

@overrides(NoticeEvent)
def get_session_id(self) -> str:
return str(self.user_id)
return f"group_{self.group_id}_{self.user_id}"


class FriendRecallNoticeEvent(NoticeEvent):
Expand Down Expand Up @@ -390,7 +390,7 @@ def get_user_id(self) -> str:

@overrides(NoticeEvent)
def get_session_id(self) -> str:
return str(self.user_id)
return f"group_{self.group_id}_{self.user_id}"


class PokeNotifyEvent(NotifyEvent):
Expand All @@ -404,6 +404,12 @@ class PokeNotifyEvent(NotifyEvent):
def is_tome(self) -> bool:
return self.target_id == self.self_id

@overrides(NotifyEvent)
def get_session_id(self) -> str:
if not self.group_id:
return str(self.user_id)
return super().get_session_id()


class LuckyKingNotifyEvent(NotifyEvent):
"""群红包运气王提醒事件"""
Expand All @@ -421,7 +427,7 @@ def get_user_id(self) -> str:

@overrides(NotifyEvent)
def get_session_id(self) -> str:
return str(self.target_id)
return f"group_{self.group_id}_{self.target_id}"


class HonorNotifyEvent(NotifyEvent):
Expand Down Expand Up @@ -490,7 +496,7 @@ def get_user_id(self) -> str:

@overrides(RequestEvent)
def get_session_id(self) -> str:
return str(self.user_id)
return f"group_{self.group_id}_{self.user_id}"

async def approve(self, bot: "Bot"):
return await bot.set_group_add_request(flag=self.flag,
Expand Down

0 comments on commit 57cf8e9

Please sign in to comment.