import { Computed, Context } from "koishi"; import { MessageContext, Middleware } from "./base"; export type UserPriorityLevel = "high" | "normal" | "low" | "ignore"; export interface CheckReplyConditionOptions { allowedChannels: string[][]; testMode: boolean; atReactPossibility: number | Computed; increaseWillingnessOn: { message: number; at: number; }; threshold: number; messageWaitTime: number; sameUserThreshold: number; decayInterval?: number; decayRate?: number; baseWillingness?: number; attentionDuration?: number; initialAttentionLevel?: number; postReplyRetention?: number; defaultUserPriority?: UserPriorityLevel; prioritySettings?: { decayMultipliers: Record; attentionMultipliers: Record; thresholdMultipliers: Record; }; userPriorities?: Record; } export declare class CheckReplyConditionMiddleware extends Middleware { ctx: Context; config: CheckReplyConditionOptions; /** * 回复意愿 * * 下列行为会增加意愿值: * - 收到消息 * - 收到 @ 消息 * - 收到 @ 消息且满足回复条件 * * 意愿值超过阈值时触发回复 * * 意愿值会随时间自然衰减,回复后会降低但不会完全重置 */ private currentThreshold; private userWillingnessMap; private userPriorityMap; private userAttentionMap; private userInteractionHistory; private lastDecayTime; private decayTimer; private channelProcessingState; private delayTimers; private lastMessageSenders; private defaultPrioritySettings; constructor(ctx: Context, config: CheckReplyConditionOptions); /** * 析构函数,清理资源 */ destroy(): void; /** * 设置用户优先级 */ setUserPriority(userId: string, level: UserPriorityLevel): void; /** * 获取用户优先级 */ getUserPriority(userId: string): UserPriorityLevel; execute(ctx: MessageContext, next: () => Promise): Promise; /** * 处理@逻辑 */ private handleMention; /** * 意愿值衰减处理 */ private decayWillingness; /** * 计算频道意愿值衰减量 */ private calculateDecayAmount; /** * 计算用户特定意愿值衰减量 */ private calculateUserDecayAmount; /** * 清理过期的用户关注状态 */ private cleanupExpiredAttention; /** * 从优先级设置中获取特定值 */ private getPrioritySettingValue; private processMessages; /** * 处理用户反馈 * @param channelId 频道ID * @param userId 用户ID * @param isPositive 是否是正面反馈 */ processUserFeedback(channelId: string, userId: string, isPositive: boolean): Promise; /** * 根据互动历史更新用户优先级 */ private updateUserPriorityBasedOnHistory; /** * 使用LLM判断用户反馈的积极性 * @param userMessages 用户最近的消息记录 * @returns 是否为积极反馈 */ /** * 构建用户反馈分析的提示词 */ private getFeedbackAnalysisPrompt; releaseChannelState(channelId: string): void; }