MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / checkChatHistory

Function checkChatHistory

pmcaptcha/pmcaptcha.ts:1127–1147  ·  view source on GitHub ↗

* 2. 聊天记录过白 (chat_history) * 用户历史消息数 >= N 时自动通过

(client: TelegramClient, userId: number, currentMsgId: number)

Source from the content-addressed store, hash-verified

1125 rec.delVerified(userId);
1126 log(LogLevel.INFO, `User ${userId} failed captcha (max tries)`);
1127 try {
1128 await client.sendMessage(peerTarget(userId), { message: "❌ 验证失败次数过多,对话已被限制。", parseMode: "html" });
1129 } catch {}
1130 if (!isStateCurrent(state)) return;
1131 await runFailActions(client, userId);
1132 } else {
1133 const hint = remaining === Infinity ? "请重试。" : `请重试(剩余次数:${remaining})`;
1134 try {
1135 const hintMsg = await client.sendMessage(peerTarget(userId), { message: `❌ 答案错误,${htmlEscape(hint)}`, parseMode: "html" });
1136 if (!isStateCurrent(state)) return;
1137 state.msgIds.push(hintMsg.id);
1138 } catch {}
1139 }
1140}
1141
1142// ─── 自动过白规则检查 ─────────────────────────────────────────────────────────
1143
1144/** 结果类型:pass=自动通过, block=自动拦截, skip=继续下一规则 */
1145type AutoRuleResult = "pass" | "block" | "skip";
1146
1147/**
1148 * 1. 主动对话过白 (initiative)
1149 * 当我方主动发起私聊时,对方自动加入白名单。
1150 * 此规则在 message.out 分支中已内置处理,此处仅作为占位标识。

Callers 1

runAutoRulesFunction · 0.85

Calls 2

logFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected