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

Function refreshActiveCaptchas

pmcaptcha/pmcaptcha.ts:789–808  ·  view source on GitHub ↗

* 刷新所有正在进行中的验证消息(在超时/次数/失败操作变更后调用)。 * 图片模式更新 caption,文字模式更新消息正文。

(client: TelegramClient)

Source from the content-addressed store, hash-verified

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
809function modeLabel(m: CaptchaMode): string {
810 return {
811 [CaptchaMode.MATH]: "算术验证",

Callers 1

pmcaptchaFunction · 0.85

Calls 4

rebuildImgCaptionFunction · 0.85
rebuildCaptchaTextFunction · 0.85
logFunction · 0.85
editMessageMethod · 0.80

Tested by

no test coverage detected