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

Method scheduleWithDelay

tmp_admin/tmp_admin.ts:663–705  ·  view source on GitHub ↗
(delay: number)

Source from the content-addressed store, hash-verified

661 }
662
663 let participant: any;
664 try {
665 participant = await this.getCurrentParticipantOrThrow(
666 job.channel,
667 job.userEntity
668 );
669 } catch (e) {
670 scheduleRetry(e);
671 return;
672 }
673
674 if (!isTemporaryAdminParticipant(participant)) {
675 this.jobs.delete(key);
676 await this.deleteStoredJobQuiet(key);
677 await this.sendReplyQuiet(
678 job,
679 `临时管理员已到期, 但 ${job.userDisplay} 已不再是插件设置的临时管理状态, 未自动解除。`
680 );
681 return;
682 }
683
684 try {
685 await this.demoteAdmin(job.client, job.channel, job.userEntity, job.originalRank);
686 } catch (e) {
687 scheduleRetry(e);
688 return;
689 }
690
691 this.jobs.delete(key);
692 await this.deleteStoredJobQuiet(key);
693 await this.sendReplyQuiet(
694 job,
695 `临时管理员已到期并自动解除: ${job.userDisplay}`
696 );
697 }, Math.min(Math.max(0, delay), maxTimerDelayMs));
698 };
699
700 const scheduleRetry = (error: any) => {
701 if (job.retryCount >= maxExpiryRetries) {
702 this.jobs.delete(key);
703 void this.deleteStoredJobQuiet(key);
704 void this.sendReplyQuiet(
705 job,
706 `临时管理员到期自动解除失败, 已重试 ${maxExpiryRetries} 次: ${codeTag(
707 error?.message || error
708 )}`

Callers

nothing calls this directly

Calls 6

deleteStoredJobQuietMethod · 0.95
sendReplyQuietMethod · 0.95
demoteAdminMethod · 0.95
deleteMethod · 0.45

Tested by

no test coverage detected