From 6caa5340a09177346e94e66b249b59f0e66ec101 Mon Sep 17 00:00:00 2001 From: LWR Date: Sat, 8 Jul 2023 00:36:32 +0800 Subject: [PATCH] feat: Custom resend interval support --- starbot/core/sender.py | 3 ++- starbot/utils/config.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/starbot/core/sender.py b/starbot/core/sender.py index 76ab29b..302bd1b 100644 --- a/starbot/core/sender.py +++ b/starbot/core/sender.py @@ -82,6 +82,7 @@ class Bot(BaseModel): await self.__bot.send_friend_message(config.get("MASTER_QQ"), "补发队列为空~") return + interval = config.get("RESEND_INTERVAL") task_start_tip = f"补发任务已启动, 补发队列长度: {len(self.__queue)}" logger.info(task_start_tip) if config.get("MASTER_QQ"): @@ -101,7 +102,7 @@ class Bot(BaseModel): self.__banned = False logger.info(f"{self.qq} -> 群[{msg_id}] : {message.safe_display}") self.__queue.pop(0) - await asyncio.sleep(3) + await asyncio.sleep(interval) except AccountMuted: logger.warning(f"Bot({self.qq}) 在群 {msg_id} 中被禁言") self.__queue.pop(0) diff --git a/starbot/utils/config.py b/starbot/utils/config.py index cd460c5..c3a8920 100644 --- a/starbot/utils/config.py +++ b/starbot/utils/config.py @@ -119,6 +119,8 @@ DEFAULT_CONFIG = { "BAN_RESEND": True, # 启用风控消息补发时,被风控时是否继续尝试发送消息,关闭后,发生风控时,后续需要发送的消息将不再尝试发送,而是被直接暂存,需使用 ”补发“ 命令后恢复正常,用于防止风控期间频繁尝试发送消息导致更严重的冻结 "BAN_CONTINUE_SEND_MESSAGE": True, + # 补发每条消息的间隔时间,频率太快可能会被再次风控,建议设置为 3 秒以上,单位:秒 + "RESEND_INTERVAL": 3, # 风控发送失败消息滞留时间上限,消息因风控滞留超出此时长不会进行补发,0 为无限制,单位:秒 "RESEND_TIME_LIMIT": 0, # 是否补发开播推送、下播推送、直播报告、动态推送中的 @全体成员 和 @群成员 消息,可能造成不必要的打扰,不推荐开启