* 刷新所有正在进行中的验证消息(在超时/次数/失败操作变更后调用)。 * 图片模式更新 caption,文字模式更新消息正文。
(client: TelegramClient)
| 787 | for (const [userId, state] of states.entries()) { |
| 788 | const promptMsgId = state.msgIds[0]; |
| 789 | if (!promptMsgId) continue; |
| 790 | try { |
| 791 | const isImg = state.mode === CaptchaMode.IMG_DIGIT || state.mode === CaptchaMode.IMG_MIXED; |
| 792 | if (isImg) { |
| 793 | const newCaption = rebuildImgCaption(state); |
| 794 | await client.editMessage(userId, { message: promptMsgId, text: newCaption }); |
| 795 | } else { |
| 796 | const newText = rebuildCaptchaText(state); |
| 797 | if (newText) { |
| 798 | await client.editMessage(userId, { message: promptMsgId, text: newText, parseMode: "html" }); |
| 799 | } |
| 800 | } |
| 801 | } catch (e) { |
| 802 | log(LogLevel.WARN, `refreshActiveCaptchas: failed to update msg for ${userId}`, e); |
| 803 | } |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | // ─── 发送验证 ───────────────────────────────────────────────────────────────── |
| 808 | |
| 809 | function modeLabel(m: CaptchaMode): string { |
| 810 | return { |
| 811 | [CaptchaMode.MATH]: "算术验证", |
no test coverage detected