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

Class CheckInPlugin

checkin/checkin.ts:86–621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84 save(partial: Partial<CheckInConfig>): void {
85 this.data = { ...this.data, ...partial };
86 try {
87 fs.writeFileSync(this.configPath, JSON.stringify(this.data, null, 2), "utf-8");
88 } catch (e) {
89 console.error("[CheckIn] Config save error:", e);
90 }
91 }
92}
93
94class CheckInPlugin extends Plugin {
95 description = this.helpText();
96 private readonly cfg = new ConfigManager();
97 private timer: NodeJS.Timeout | null = null;
98 private running = false;
99 private todayRunTime: string | null = null;
100 private pendingAdds = new Map<string, PendingAdd>();
101
102 constructor() {
103 super();
104 this.timer = setInterval(() => void this.checkAndRun(), 60_000);
105 }
106
107 cleanup(): void {
108 if (this.timer) clearInterval(this.timer);
109 this.timer = null;
110 }
111
112 cmdHandlers: Record<string, (msg: Api.Message) => Promise<void>> = {
113 checkin: async (msg: Api.Message) => {
114 try {
115 const parts = (msg.message || msg.text || "").trim().split(/\s+/);
116 const args = parts.slice(1);
117 const action = (args[0] || "").toLowerCase();
118
119 if (!action || action === "help" || action === "h") {
120 if (!action && this.cfg.get().targets.length > 0) {
121 await this.edit(msg, "🚀 开始执行所有签到任务...");
122 void this.runAllSigns("手动触发", msg.chatId, msg);
123 return;
124 }
125 await this.edit(msg, this.helpText());
126 return;
127 }
128
129 if (["add", "del", "delete", "list", "toggle", "test"].includes(action)) {
130 await this.handleTargetCommand(action, args, msg);
131 return;
132 }
133
134 if (["set", "config", "settings", "info"].includes(action)) {
135 await this.handleConfigCommand(action, args, msg);
136 return;
137 }
138
139 if (action === "reset") {
140 this.cfg.save({ lastRunDate: "", currentRunTime: undefined });
141 this.todayRunTime = null;
142 await this.edit(msg, "✅ 已重置每日运行状态,定时任务可再次触发。");
143 return;

Callers

nothing calls this directly

Calls 9

helpTextMethod · 0.95
editMethod · 0.95
runAllSignsMethod · 0.95
handleTargetCommandMethod · 0.95
handleConfigCommandMethod · 0.95
escapeMethod · 0.95
saveMethod · 0.80
errorMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected