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 <[email protected]>
This commit is contained in:
2026-06-26 14:08:05 +08:00
co-authored by Claude Opus 4.8
parent bc61e99013
commit 59a98830cd
+5
View File
@@ -196,6 +196,11 @@ object JChatGPT : KotlinPlugin(
private suspend fun onMessage(event: MessageEvent) { private suspend fun onMessage(event: MessageEvent) {
// 检查Token是否设置 // 检查Token是否设置
if (LargeLanguageModels.chat == null) return 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.toCommandSender().hasPermission(chatPermission)) {
if (event is GroupMessageEvent) { if (event is GroupMessageEvent) {