mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
fix(zhenxun): 修复直播广播 bot 对象获取问题
- 当传入的 bot 对象不存在时,尝试获取默认 bot 对象 - 优化了日志输出,增加了获取默认 bot 对象时的日志记录 - 提高了代码的健壮性,确保在没有可用 bot 对象时抛出异常
This commit is contained in:
parent
24f289e464
commit
96385dc10a
@ -529,9 +529,16 @@ class BroadcastEngine:
|
|||||||
try:
|
try:
|
||||||
self.bot_list.append(nonebot.get_bot(i))
|
self.bot_list.append(nonebot.get_bot(i))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.warning(f"Bot:{i} 对象未连接或不存在")
|
logger.warning(f"Bot:{i} 对象未连接或不存在", log_cmd)
|
||||||
if not self.bot_list:
|
if not self.bot_list:
|
||||||
raise ValueError("当前没有可用的Bot对象...", log_cmd)
|
try:
|
||||||
|
bot = nonebot.get_bot()
|
||||||
|
self.bot_list.append(bot)
|
||||||
|
logger.debug(
|
||||||
|
f"广播任务未传入Bot对象,使用默认Bot {bot.self_id}", log_cmd
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
raise ValueError("当前没有可用的Bot对象...", log_cmd)
|
||||||
|
|
||||||
async def call_check(self, bot: Bot, group_id: str) -> bool:
|
async def call_check(self, bot: Bot, group_id: str) -> bool:
|
||||||
"""运行发送检测函数
|
"""运行发送检测函数
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user