conversation: preserve triggers and await follow-ups

This commit is contained in:
2026-08-05 20:24:19 +08:00
parent c931d39d20
commit f416d889b3
13 changed files with 712 additions and 51 deletions
+18 -7
View File
@@ -131,6 +131,12 @@ object JChatGPT : KotlinPlugin(
private suspend fun onMessage(event: MessageEvent) {
if (LargeLanguageModels.chat == null) return
if (ConversationEngine.isExpectedUser(event)) {
if (shouldIgnoreBecauseMuted(event)) return
if (ConversationEngine.resumeObserved(event)) return
}
if (!event.toCommandSender().hasPermission(chatPermission)) {
if (event is GroupMessageEvent) {
if (!PluginConfig.groupOpHasChatPermission || !event.sender.isOperator()) {
@@ -145,18 +151,23 @@ object JChatGPT : KotlinPlugin(
event.message[QuoteReply]?.source?.fromId == event.bot.id
if (!triggered) return
if (event is GroupMessageEvent && event.group.botMuteRemaining > 0) {
logger.info(
"bot 在群 ${event.group.name}(${event.group.id}) 被禁言," +
"剩余 ${event.group.botMuteRemaining} 秒,忽略消息"
)
return
}
if (shouldIgnoreBecauseMuted(event)) return
if (PluginConfig.enableFavorabilitySystem && shouldIgnoreForFavorability(event)) return
ConversationEngine.start(event)
}
private fun shouldIgnoreBecauseMuted(event: MessageEvent): Boolean {
if (event !is GroupMessageEvent) return false
val remainingSeconds = event.group.botMuteRemaining
if (remainingSeconds <= 0) return false
logger.info(
"bot 在群 ${event.group.name}(${event.group.id}) 被禁言," +
"剩余 $remainingSeconds 秒,忽略消息"
)
return true
}
private suspend fun shouldIgnoreForFavorability(event: MessageEvent): Boolean {
val info = PluginData.userFavorability[event.sender.id] ?: return false
if (info.value >= 0) return false