From 59a98830cd90092822b52f5724a98658f731081e Mon Sep 17 00:00:00 2001 From: jie65535 Date: Fri, 26 Jun 2026 14:08:05 +0800 Subject: [PATCH] Skip muted-group messages to avoid wasting tokens When the bot is muted in a group it cannot send replies, so process nothing: short-circuit in onMessage before any trigger/LLM work using Group.botMuteRemaining. Co-Authored-By: Claude Opus 4.8 --- src/main/kotlin/JChatGPT.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/kotlin/JChatGPT.kt b/src/main/kotlin/JChatGPT.kt index d4c9445..d9011b0 100644 --- a/src/main/kotlin/JChatGPT.kt +++ b/src/main/kotlin/JChatGPT.kt @@ -196,6 +196,11 @@ object JChatGPT : KotlinPlugin( private suspend fun onMessage(event: MessageEvent) { // 检查Token是否设置 if (LargeLanguageModels.chat == null) return + // 如果bot在群里被禁言,则无法发言,直接结束,避免浪费token + if (event is GroupMessageEvent && event.group.botMuteRemaining > 0) { + logger.info("bot 在群 ${event.group.name}(${event.group.id}) 被禁言,剩余 ${event.group.botMuteRemaining} 秒,忽略消息") + return + } // 发送者是否有权限 if (!event.toCommandSender().hasPermission(chatPermission)) { if (event is GroupMessageEvent) {