🐛 修复按钮回调消息事件无响应问题 (#621)

*  修复按钮回调消息事件无响应问题

* 🚨 `pre-commit-ci`修复格式错误

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
季落 2024-02-28 15:40:15 +08:00 committed by GitHub
parent 9ba292ad0b
commit 19cd7525f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,12 +47,10 @@ else:
async def get_notice_message(bot: Bot, ev: Event): async def get_notice_message(bot: Bot, ev: Event):
if gsclient is None: if gsclient is None:
return await connect() return await connect()
try: try:
await gsclient.ws.ping() await gsclient.ws.ping()
except ConnectionClosed: except ConnectionClosed:
return await connect() return await connect()
raw_data = ev.dict() raw_data = ev.dict()
logger.debug(raw_data) logger.debug(raw_data)
@ -209,7 +207,7 @@ async def get_notice_message(bot: Bot, ev: Event):
else: else:
logger.debug('[gsuid] 不支持该 Discord 事件...') logger.debug('[gsuid] 不支持该 Discord 事件...')
return return
elif bot.adapter.get_name() == 'qq': elif bot.adapter.get_name() == 'QQ':
from nonebot.adapters.qq.bot import Bot from nonebot.adapters.qq.bot import Bot
from nonebot.adapters.qq.event import InteractionCreateEvent from nonebot.adapters.qq.event import InteractionCreateEvent
@ -233,15 +231,15 @@ async def get_notice_message(bot: Bot, ev: Event):
user_type = 'direct' user_type = 'direct'
user_id = str(ev.user_openid) user_id = str(ev.user_openid)
message = [Message('text', ev.data.resolved.button_data)] message = [Message('text', ev.data.resolved.button_data)]
await bot.put_interaction(interaction_id=ev.id, code=0) await bot.put_interaction(interaction_id=ev.id, code=0)
else: else:
logger.debug('[gsuid] 不支持该 QQ 事件...') logger.debug('[gsuid] 不支持该 QQ 事件...')
return return
else: else:
return return
msg = MessageReceive( msg = MessageReceive(
bot_id=bot_id, bot_id=sp_bot_id if sp_bot_id else bot_id,
bot_self_id=self_id, bot_self_id=self_id,
user_type=sp_user_type if sp_user_type else user_type, user_type=sp_user_type if sp_user_type else user_type,
group_id=group_id, group_id=group_id,
@ -259,7 +257,6 @@ async def get_notice_message(bot: Bot, ev: Event):
async def get_all_message(bot: Bot, ev: Event): async def get_all_message(bot: Bot, ev: Event):
if gsclient is None: if gsclient is None:
return await connect() return await connect()
try: try:
await gsclient.ws.ping() await gsclient.ws.ping()
except ConnectionClosed: except ConnectionClosed:
@ -643,7 +640,6 @@ async def get_all_message(bot: Bot, ev: Event):
if not message: if not message:
return return
msg = MessageReceive( msg = MessageReceive(
bot_id=bot_id, bot_id=bot_id,
bot_self_id=self_id, bot_self_id=self_id,