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

Method scheduleTimeout

autodelcmd/autodelcmd.ts:94–106  ·  view source on GitHub ↗
(callback: () => void | Promise<void>, delayMs: number)

Source from the content-addressed store, hash-verified

92 timer = setTimeout(async () => {
93 this.pendingTimeouts.delete(timer);
94 try {
95 await callback();
96 } catch (error) {
97 console.error("[autodelcmd] 定时任务执行失败:", error);
98 }
99 }, delayMs);
100 this.pendingTimeouts.add(timer);
101 return timer;
102 }
103
104 public cleanup(): void {
105 // 真实资源清理:释放插件持有的定时器、监听器、运行时状态或临时资源。
106 for (const timer of this.pendingTimeouts) {
107 clearTimeout(timer);
108 }
109 this.pendingTimeouts.clear();

Callers 2

autoDeleteOnStartupMethod · 0.95
delayDeleteMethod · 0.95

Calls 4

callbackFunction · 0.85
errorMethod · 0.80
deleteMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected