* 执行所有自动过白规则(按优先级顺序) * 返回 true 表示已处理(通过或拦截),messageListener 应直接返回 * 返回 false 表示继续走验证码流程
(client: TelegramClient, userId: number, message: Api.Message)
| 1269 | // 规则 1: initiative 已在 message.out 分支中处理 |
| 1270 | |
| 1271 | // 规则 2: 聊天记录过白 |
| 1272 | const historyResult = await checkChatHistory(client, userId, message.id); |
| 1273 | if (historyResult === "pass") return true; |
| 1274 | if (historyResult === "block") { |
| 1275 | await executeBlockActions(client, userId); |
| 1276 | return true; |
| 1277 | } |
| 1278 | |
| 1279 | // 规则 3: 共同群过白 |
| 1280 | const groupsResult = await checkGroupsInCommon(client, userId); |
| 1281 | if (groupsResult === "pass") return true; |
| 1282 | if (groupsResult === "block") { |
| 1283 | await executeBlockActions(client, userId); |
| 1284 | return true; |
| 1285 | } |
| 1286 | |
| 1287 | // 规则 4: 关键词过白 / 黑名单拦截 |
| 1288 | const wordResult = await checkWordFilter(client, userId, message); |
| 1289 | if (wordResult === "pass") return true; |
| 1290 | if (wordResult === "block") { |
| 1291 | await executeBlockActions(client, userId); |
| 1292 | return true; |
| 1293 | } |
| 1294 | |
| 1295 | // 规则 5: Premium 用户策略 |
| 1296 | const premiumResult = await checkPremium(client, userId, message); |
| 1297 | if (premiumResult === "pass") return true; |
| 1298 | if (premiumResult === "block") { |
| 1299 | await executeBlockActions(client, userId); |
| 1300 | return true; |
| 1301 | } |
| 1302 | |
| 1303 | return false; // 所有规则都未触发,继续正常验证流程 |
| 1304 | } |
| 1305 | |
| 1306 | /** |
| 1307 | * 执行自动拦截操作(黑名单/Premium ban 等触发时) |
| 1308 | * 复用 captcha 失败的操作逻辑 |
| 1309 | */ |
| 1310 | async function executeBlockActions(client: TelegramClient, userId: number) { |
no test coverage detected