Skip to content

Commit

Permalink
🐛 Fix: 修复只有 private bot 时候的推送 bot 获取 (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyongyu authored Feb 1, 2025
1 parent 83afc8e commit 0b58879
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/providers/platform/extractors/qq.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,13 @@ def extract_reply_message(cls, event) -> MessageInfo | None:
async def get_target_bot(cls, target) -> Bot:
bots = [bot for bot in nonebot.get_bots().values() if isinstance(bot, Bot)]
private_bots = [bot for bot in bots if bot.bot_info.intent.guild_messages]
public_bot = next(bot for bot in bots if not bot.bot_info.intent.guild_messages)
public_bot = next(bot for bot in bots if not bot.bot_info.intent.guild_messages, None)

Check failure on line 157 in src/providers/platform/extractors/qq.py

View workflow job for this annotation

GitHub Actions / Pyright Lint

Generator expressions must be parenthesized if not sole argument
if public_bot is None and not private_bot:

Check failure on line 158 in src/providers/platform/extractors/qq.py

View workflow job for this annotation

GitHub Actions / Pyright Lint

"private_bot" is not defined (reportUndefinedVariable)
raise RuntimeError("No QQ bot available")
if isinstance(
target, QQOfficialUserInfo | QQOfficialGroupInfo | QQGuildUserInfo
):
return public_bot
return public_bot or private_bots[0]
for bot in private_bots:
try:
setting = await bot.get_message_setting(guild_id=target.qq_guild_id)
Expand All @@ -171,7 +173,7 @@ async def get_target_bot(cls, target) -> Bot:
continue
if target.qq_channel_id not in setting.channel_ids:
continue
return public_bot
return public_bot or private_bot[0]

Check failure on line 176 in src/providers/platform/extractors/qq.py

View workflow job for this annotation

GitHub Actions / Pyright Lint

"private_bot" is not defined (reportUndefinedVariable)

@classmethod
@override
Expand Down

0 comments on commit 0b58879

Please sign in to comment.