mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-14 21:52:56 +08:00
fix(zhenxun): 修复广播插件未传入 Bot 对象时的处理逻辑 (#1960)
- 增加了当未传入 Bot 对象时,尝试使用默认 Bot 的逻辑 - 优化了错误日志和异常处理,提高了代码的健壮性
This commit is contained in:
parent
1c5f66beee
commit
1e7ae38684
@ -529,9 +529,16 @@ class BroadcastEngine:
|
||||
try:
|
||||
self.bot_list.append(nonebot.get_bot(i))
|
||||
except KeyError:
|
||||
logger.warning(f"Bot:{i} 对象未连接或不存在")
|
||||
logger.warning(f"Bot:{i} 对象未连接或不存在", log_cmd)
|
||||
if not self.bot_list:
|
||||
raise ValueError("当前没有可用的Bot对象...", log_cmd)
|
||||
try:
|
||||
bot = nonebot.get_bot()
|
||||
self.bot_list.append(bot)
|
||||
logger.warning(
|
||||
f"广播任务未传入Bot对象,使用默认Bot {bot.self_id}", log_cmd
|
||||
)
|
||||
except Exception as e:
|
||||
raise ValueError("当前没有可用的Bot对象...", log_cmd) from e
|
||||
|
||||
async def call_check(self, bot: Bot, group_id: str) -> bool:
|
||||
"""运行发送检测函数
|
||||
|
||||
Loading…
Reference in New Issue
Block a user