mirror of
https://github.com/jie65535/JChatGPT.git
synced 2026-09-15 02:56:10 +08:00
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:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user