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

Function getFloodWaitSeconds

aban/aban.ts:36–47  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

34 return pLimit;
35}
36
37// 解析 FLOOD_WAIT 错误中的等待秒数;非 flood 错返回 null
38function getFloodWaitSeconds(error: unknown): number | null {
39 const msg = error instanceof Error ? error.message : String(error || "");
40 // teleproto 抛出的 RPCError 里通常带 "FLOOD_WAIT_X" 或 "wait of N seconds"
41 let m = msg.match(/FLOOD_WAIT_(\d+)/);
42 if (m) return parseInt(m[1], 10);
43 m = msg.match(/wait of (\d+) seconds?/i);
44 if (m) return parseInt(m[1], 10);
45 // teleproto FloodWaitError 的 seconds 字段
46 const seconds = (error as any)?.seconds;
47 if (typeof seconds === "number" && Number.isFinite(seconds)) return seconds;
48 return null;
49}
50

Callers 1

attemptMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected