* 执行自动拦截操作(黑名单/Premium ban 等触发时) * 复用 captcha 失败的操作逻辑
(client: TelegramClient, userId: number)
| 1311 | try { |
| 1312 | await archiveChat(client, userId); |
| 1313 | await muteChat(client, userId); |
| 1314 | const actions = cfg.failActions(); |
| 1315 | for (const action of actions) { |
| 1316 | switch (action) { |
| 1317 | case FailAction.BLOCK: |
| 1318 | try { await client.invoke(new Api.contacts.Block({ id: userId })); } catch {} |
| 1319 | break; |
| 1320 | case FailAction.REPORT: |
| 1321 | try { await client.invoke(new Api.account.ReportPeer({ peer: userId, reason: new Api.InputReportReasonSpam(), message: "" })); } catch {} |
| 1322 | break; |
| 1323 | case FailAction.DELETE: |
| 1324 | try { await client.invoke(new Api.messages.DeleteHistory({ peer: userId, maxId: 0, justClear: false, revoke: true })); } catch {} |
| 1325 | break; |
| 1326 | } |
| 1327 | } |
| 1328 | const name = await getDisplayName(client, userId).catch(() => String(userId)); |
| 1329 | rec.addFailed(userId, name, "max_tries", usernameCache.get(userId)); |
| 1330 | log(LogLevel.INFO, `Auto-block actions executed for user ${userId}`); |
| 1331 | } catch (e) { |
| 1332 | log(LogLevel.ERROR, `executeBlockActions failed for ${userId}`, e); |
| 1333 | } |
| 1334 | } |
| 1335 | |
| 1336 | // ─── 消息监听 ───────────────────────────────────────────────────────────────── |
| 1337 | |
| 1338 | async function messageListener(message: Api.Message) { |
| 1339 | if (!getActiveLifecycle()) return; |
| 1340 | if (!(await waitDb())) return; |
no test coverage detected