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

Method handleAddTask

sendat/sendat.ts:612–648  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

610 }
611 }
612
613 private async handleAddTask(msg: Api.Message): Promise<void> {
614 const text = msg.text || "";
615 const commandMatch = text.match(/^[.!。]sendat\s+(.+)/i);
616
617 if (!commandMatch) {
618 await msg.edit({ text: "❌ 命令格式错误", parseMode: "html" });
619 return;
620 }
621
622 const taskContent = commandMatch[1].trim();
623 const chatId = msg.chatId?.toJSNumber() || 0;
624
625 const task = new SendTask({
626 task_id: this.taskManager.getNextTaskId(),
627 cid: chatId,
628 msg: "",
629 interval: false,
630 cron: false,
631 pause: false,
632 time_limit: -1,
633 hour: "0",
634 minute: "0",
635 second: "0"
636 });
637
638 try {
639 task.parseTask(taskContent);
640 await this.taskManager.addTask(task);
641
642 await msg.edit({
643 text: `✅ <b>已添加任务 #${task.task_id}</b>\n\n${task.getDescription()}`,
644 parseMode: "html"
645 });
646 } catch (error: any) {
647 throw new Error(`添加任务失败: ${error.message}`);
648 }
649 }
650}
651

Callers 1

handleSendAtCommandMethod · 0.95

Calls 5

parseTaskMethod · 0.95
getDescriptionMethod · 0.95
addTaskMethod · 0.80
editMethod · 0.45
getNextTaskIdMethod · 0.45

Tested by

no test coverage detected