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

Method helpText

checkin/checkin.ts:530–562  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

528 return this.isAfterMessage(m, sentId);
529 });
530 if (!first) return { success: false, error: "未收到签到结果" };
531
532 if (!this.hasMatcher(target)) return { success: true, message: first.message || "签到命令已发送" };
533 await this.clickCallbackButton(client, target.target, first, target);
534
535 const second = await this.waitForNewMessage(client, target.target, Math.floor(Date.now() / 1000), 10_000, (m) => !m.out);
536 return { success: true, message: second?.message || first.message || "已点击签到按钮" };
537 } catch (e: any) {
538 return { success: false, error: e?.message || "执行失败" };
539 }
540 }
541
542 private async waitForNewMessage(
543 client: any,
544 peer: string,
545 minDate: number,
546 timeoutMs: number,
547 filter?: (m: Api.Message) => boolean
548 ): Promise<Api.Message | null> {
549 const start = Date.now();
550 while (Date.now() - start < timeoutMs) {
551 try {
552 await this.sleep(1000);
553 const msgs = await client.getMessages(peer, { limit: 8 });
554 for (const m of msgs) {
555 if (m.date < minDate) continue;
556 if (!filter || filter(m)) return m;
557 }
558 } catch (e) {
559 console.error("[CheckIn] Polling error:", e);
560 }
561 }
562 return null;
563 }
564
565 private async clickCallbackButton(client: any, peer: string, msg: Api.Message, target: SignTarget): Promise<void> {

Callers 1

CheckInPluginClass · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected