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

Method handleTargetCommand

checkin/checkin.ts:147–214  ·  view source on GitHub ↗
(action: string, args: string[], msg: Api.Message)

Source from the content-addressed store, hash-verified

145 this.cfg.save({ lastRunDate: "", currentRunTime: undefined });
146 this.todayRunTime = null;
147 await this.edit(msg, "✅ 已重置每日运行状态,定时任务可再次触发。");
148 return;
149 }
150
151 await this.edit(msg, `❌ 未知命令,请使用 ${PREFIX}checkin help 查看帮助`);
152 } catch (e: any) {
153 console.error("[CheckIn] Command error:", e);
154 try {
155 await this.edit(msg, `❌ 命令执行失败: ${this.escape(e?.message || "未知错误")}`);
156 } catch {}
157 }
158 },
159 };
160
161 // ── 回复式添加:监听用户回复以获取签到命令 ─
162 listenMessageHandler = async (msg: Api.Message, _options?: { isEdited?: boolean }) => {
163 if (_options?.isEdited) return;
164 const chatId = String(msg.chatId || msg.peerId || "");
165 const pending = this.pendingAdds.get(chatId);
166 if (!pending) return;
167
168 const replyToMsgId = (msg as any).replyTo?.replyToMsgId ?? (msg as any).replyToMsgId;
169 if (replyToMsgId !== pending.promptMsgId) return;
170
171 const command = (msg.message || msg.text || "").trim();
172 if (!command) {
173 const client = await getGlobalClient();
174 await client?.sendMessage(chatId, {
175 message: "❌ 签到命令不能为空,请重新回复此消息",
176 parseMode: "html",
177 linkPreview: false,
178 });
179 return;
180 }
181
182 this.pendingAdds.delete(chatId);
183
184 const conf = this.cfg.get();
185 const next: SignTarget = {
186 id: pending.id,
187 name: pending.name,
188 target: pending.target,
189 command,
190 ...pending.matcher,
191 enabled: true,
192 };
193 const i = conf.targets.findIndex((t) => t.id === pending.id);
194 if (i >= 0) conf.targets[i] = next;
195 else conf.targets.push(next);
196 this.cfg.save({ targets: conf.targets });
197
198 const client = await getGlobalClient();
199 await client?.sendMessage(chatId, {
200 message: `✅ 已${i >= 0 ? "更新" : "添加"}签到目标: ${pending.name} (${pending.id})\n命令: ${this.escape(command)}`,
201 parseMode: "html",
202 linkPreview: false,
203 });
204 };

Callers 1

CheckInPluginClass · 0.95

Calls 6

editMethod · 0.95
parseButtonMatcherMethod · 0.95
escapeMethod · 0.95
runSingleSignMethod · 0.95
saveMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected