mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-02-20 09:38:23 +08:00
🐛 fix cqhttp event session id mismatch for group
This commit is contained in:
parent
f609a9fe0e
commit
57cf8e9bd8
@ -232,7 +232,7 @@ class GroupUploadNoticeEvent(NoticeEvent):
|
|||||||
|
|
||||||
@overrides(NoticeEvent)
|
@overrides(NoticeEvent)
|
||||||
def get_session_id(self) -> str:
|
def get_session_id(self) -> str:
|
||||||
return str(self.user_id)
|
return f"group_{self.group_id}_{self.user_id}"
|
||||||
|
|
||||||
|
|
||||||
class GroupAdminNoticeEvent(NoticeEvent):
|
class GroupAdminNoticeEvent(NoticeEvent):
|
||||||
@ -253,7 +253,7 @@ class GroupAdminNoticeEvent(NoticeEvent):
|
|||||||
|
|
||||||
@overrides(NoticeEvent)
|
@overrides(NoticeEvent)
|
||||||
def get_session_id(self) -> str:
|
def get_session_id(self) -> str:
|
||||||
return str(self.user_id)
|
return f"group_{self.group_id}_{self.user_id}"
|
||||||
|
|
||||||
|
|
||||||
class GroupDecreaseNoticeEvent(NoticeEvent):
|
class GroupDecreaseNoticeEvent(NoticeEvent):
|
||||||
@ -275,7 +275,7 @@ class GroupDecreaseNoticeEvent(NoticeEvent):
|
|||||||
|
|
||||||
@overrides(NoticeEvent)
|
@overrides(NoticeEvent)
|
||||||
def get_session_id(self) -> str:
|
def get_session_id(self) -> str:
|
||||||
return str(self.user_id)
|
return f"group_{self.group_id}_{self.user_id}"
|
||||||
|
|
||||||
|
|
||||||
class GroupIncreaseNoticeEvent(NoticeEvent):
|
class GroupIncreaseNoticeEvent(NoticeEvent):
|
||||||
@ -297,7 +297,7 @@ class GroupIncreaseNoticeEvent(NoticeEvent):
|
|||||||
|
|
||||||
@overrides(NoticeEvent)
|
@overrides(NoticeEvent)
|
||||||
def get_session_id(self) -> str:
|
def get_session_id(self) -> str:
|
||||||
return str(self.user_id)
|
return f"group_{self.group_id}_{self.user_id}"
|
||||||
|
|
||||||
|
|
||||||
class GroupBanNoticeEvent(NoticeEvent):
|
class GroupBanNoticeEvent(NoticeEvent):
|
||||||
@ -320,7 +320,7 @@ class GroupBanNoticeEvent(NoticeEvent):
|
|||||||
|
|
||||||
@overrides(NoticeEvent)
|
@overrides(NoticeEvent)
|
||||||
def get_session_id(self) -> str:
|
def get_session_id(self) -> str:
|
||||||
return str(self.user_id)
|
return f"group_{self.group_id}_{self.user_id}"
|
||||||
|
|
||||||
|
|
||||||
class FriendAddNoticeEvent(NoticeEvent):
|
class FriendAddNoticeEvent(NoticeEvent):
|
||||||
@ -357,7 +357,7 @@ class GroupRecallNoticeEvent(NoticeEvent):
|
|||||||
|
|
||||||
@overrides(NoticeEvent)
|
@overrides(NoticeEvent)
|
||||||
def get_session_id(self) -> str:
|
def get_session_id(self) -> str:
|
||||||
return str(self.user_id)
|
return f"group_{self.group_id}_{self.user_id}"
|
||||||
|
|
||||||
|
|
||||||
class FriendRecallNoticeEvent(NoticeEvent):
|
class FriendRecallNoticeEvent(NoticeEvent):
|
||||||
@ -390,7 +390,7 @@ class NotifyEvent(NoticeEvent):
|
|||||||
|
|
||||||
@overrides(NoticeEvent)
|
@overrides(NoticeEvent)
|
||||||
def get_session_id(self) -> str:
|
def get_session_id(self) -> str:
|
||||||
return str(self.user_id)
|
return f"group_{self.group_id}_{self.user_id}"
|
||||||
|
|
||||||
|
|
||||||
class PokeNotifyEvent(NotifyEvent):
|
class PokeNotifyEvent(NotifyEvent):
|
||||||
@ -404,6 +404,12 @@ class PokeNotifyEvent(NotifyEvent):
|
|||||||
def is_tome(self) -> bool:
|
def is_tome(self) -> bool:
|
||||||
return self.target_id == self.self_id
|
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):
|
class LuckyKingNotifyEvent(NotifyEvent):
|
||||||
"""群红包运气王提醒事件"""
|
"""群红包运气王提醒事件"""
|
||||||
@ -421,7 +427,7 @@ class LuckyKingNotifyEvent(NotifyEvent):
|
|||||||
|
|
||||||
@overrides(NotifyEvent)
|
@overrides(NotifyEvent)
|
||||||
def get_session_id(self) -> str:
|
def get_session_id(self) -> str:
|
||||||
return str(self.target_id)
|
return f"group_{self.group_id}_{self.target_id}"
|
||||||
|
|
||||||
|
|
||||||
class HonorNotifyEvent(NotifyEvent):
|
class HonorNotifyEvent(NotifyEvent):
|
||||||
@ -490,7 +496,7 @@ class GroupRequestEvent(RequestEvent):
|
|||||||
|
|
||||||
@overrides(RequestEvent)
|
@overrides(RequestEvent)
|
||||||
def get_session_id(self) -> str:
|
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"):
|
async def approve(self, bot: "Bot"):
|
||||||
return await bot.set_group_add_request(flag=self.flag,
|
return await bot.set_group_add_request(flag=self.flag,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user