Skip to content

Commit 079bc20

Browse files
author
Yingwen Luo
committed
chore: remove opencode_start and opencode_stop commands from DingTalk and Feishu
- Remove handleOpencodeStartCommand function from DingTalk handler - Remove handleOpencodeStopCommand function from DingTalk handler - Remove opencode_start and opencode_stop from DingTalk command list - Remove opencode_start and opencode_stop from DingTalk valid commands - Remove command handlers for /opencode_start and /opencode_stop in DingTalk - Remove handleOpencodeStartCommand function from Feishu handler - Remove handleOpencodeStopCommand function from Feishu handler - Remove opencode_start and opencode_stop from Feishu command list - Remove opencode_start and opencode_stop from Feishu valid commands - Remove command handlers for /opencode_start and /opencode_stop in Feishu
1 parent a19403f commit 079bc20

File tree

2 files changed

+0
-230
lines changed

2 files changed

+0
-230
lines changed

src/dingtalk/handler.ts

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -533,110 +533,6 @@ async function handleRenameCommand(userId: string): Promise<void> {
533533
}
534534
}
535535

536-
async function handleOpencodeStartCommand(userId: string): Promise<void> {
537-
try {
538-
if (processManager.isRunning()) {
539-
const uptime = processManager.getUptime();
540-
const uptimeStr = uptime ? Math.floor(uptime / 1000) : 0;
541-
await sendDingTalkMessage(
542-
userId,
543-
t("opencode_start.already_running_managed", {
544-
pid: processManager.getPID() ?? "-",
545-
seconds: uptimeStr,
546-
}),
547-
);
548-
return;
549-
}
550-
551-
try {
552-
const { data, error } = await opencodeClient.global.health();
553-
if (!error && data?.healthy) {
554-
await sendDingTalkMessage(
555-
userId,
556-
t("opencode_start.already_running_external", {
557-
version: data.version || t("common.unknown"),
558-
}),
559-
);
560-
return;
561-
}
562-
} catch {
563-
// Continue with start
564-
}
565-
566-
await sendDingTalkMessage(userId, t("opencode_start.starting"));
567-
568-
const { success, error } = await processManager.start();
569-
570-
if (!success) {
571-
await sendDingTalkMessage(
572-
userId,
573-
t("opencode_start.start_error", { error: error || t("common.unknown_error") }),
574-
);
575-
return;
576-
}
577-
578-
const ready = await waitForServerReadyDingTalk(10000);
579-
if (!ready) {
580-
await sendDingTalkMessage(
581-
userId,
582-
t("opencode_start.started_not_ready", { pid: processManager.getPID() ?? "-" }),
583-
);
584-
return;
585-
}
586-
587-
const { data: health } = await opencodeClient.global.health();
588-
await sendDingTalkMessage(
589-
userId,
590-
t("opencode_start.success", {
591-
pid: processManager.getPID() ?? "-",
592-
version: health?.version || t("common.unknown"),
593-
}),
594-
);
595-
596-
logger.info(`[DingTalk] OpenCode server started, PID=${processManager.getPID()}`);
597-
} catch (err) {
598-
logger.error("[DingTalk] Error in opencode_start command:", err);
599-
await sendDingTalkMessage(userId, t("opencode_start.error"));
600-
}
601-
}
602-
603-
async function handleOpencodeStopCommand(userId: string): Promise<void> {
604-
try {
605-
if (!processManager.isRunning()) {
606-
try {
607-
const { data, error } = await opencodeClient.global.health();
608-
if (!error && data?.healthy) {
609-
await sendDingTalkMessage(userId, t("opencode_stop.external_running"));
610-
return;
611-
}
612-
} catch {
613-
// Server not accessible
614-
}
615-
await sendDingTalkMessage(userId, t("opencode_stop.not_running"));
616-
return;
617-
}
618-
619-
const pid = processManager.getPID();
620-
await sendDingTalkMessage(userId, t("opencode_stop.stopping", { pid: pid ?? "-" }));
621-
622-
const { success, error } = await processManager.stop(5000);
623-
624-
if (!success) {
625-
await sendDingTalkMessage(
626-
userId,
627-
t("opencode_stop.stop_error", { error: error || t("common.unknown_error") }),
628-
);
629-
return;
630-
}
631-
632-
await sendDingTalkMessage(userId, t("opencode_stop.success"));
633-
logger.info("[DingTalk] OpenCode server stopped");
634-
} catch (err) {
635-
logger.error("[DingTalk] Error in opencode_stop command:", err);
636-
await sendDingTalkMessage(userId, t("opencode_stop.error"));
637-
}
638-
}
639-
640536
async function handleHelpCommand(userId: string): Promise<void> {
641537
const commands = getLocalizedBotCommandsDingTalk();
642538
const lines = commands.map((item) => `/${item.command} - ${item.description}`);
@@ -742,8 +638,6 @@ function getLocalizedBotCommandsDingTalk(): { command: string; description: stri
742638
{ command: "task", description: t("cmd.description.task") },
743639
{ command: "tasklist", description: t("cmd.description.tasklist") },
744640
{ command: "commands", description: t("cmd.description.commands") },
745-
{ command: "opencode_start", description: t("cmd.description.opencode_start") },
746-
{ command: "opencode_stop", description: t("cmd.description.opencode_stop") },
747641
{ command: "exit", description: t("cmd.description.exit") },
748642
{ command: "help", description: t("cmd.description.help") },
749643
];
@@ -764,8 +658,6 @@ function getValidCommands(): string[] {
764658
"task",
765659
"tasklist",
766660
"commands",
767-
"opencode_start",
768-
"opencode_stop",
769661
"exit",
770662
"help",
771663
];
@@ -1079,10 +971,6 @@ function processMessage(userId: string, text: string, sessionWebhook: string): v
1079971
const message = await handleCommandsCommand(userId);
1080972
await sendDingTalkMessage(userId, message);
1081973
})();
1082-
} else if (text.startsWith("/opencode_start")) {
1083-
void handleOpencodeStartCommand(userId);
1084-
} else if (text.startsWith("/opencode_stop")) {
1085-
void handleOpencodeStopCommand(userId);
1086974
} else if (text.startsWith("/exit")) {
1087975
void handleExitCommand(userId);
1088976
} else if (text.startsWith("/tasklist")) {

src/feishu/handler.ts

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -555,116 +555,6 @@ async function handleRenameCommand(chatId: string, userId: string): Promise<void
555555
}
556556
}
557557

558-
async function handleOpencodeStartCommand(chatId: string, userId: string): Promise<void> {
559-
try {
560-
if (processManager.isRunning()) {
561-
const uptime = processManager.getUptime();
562-
const uptimeStr = uptime ? Math.floor(uptime / 1000) : 0;
563-
await sendFeishuMessage(
564-
chatId,
565-
userId,
566-
t("opencode_start.already_running_managed", {
567-
pid: processManager.getPID() ?? "-",
568-
seconds: uptimeStr,
569-
}),
570-
);
571-
return;
572-
}
573-
574-
try {
575-
const { data, error } = await opencodeClient.global.health();
576-
if (!error && data?.healthy) {
577-
await sendFeishuMessage(
578-
chatId,
579-
userId,
580-
t("opencode_start.already_running_external", {
581-
version: data.version || t("common.unknown"),
582-
}),
583-
);
584-
return;
585-
}
586-
} catch {
587-
// Continue with start
588-
}
589-
590-
await sendFeishuMessage(chatId, userId, t("opencode_start.starting"));
591-
592-
const { success, error } = await processManager.start();
593-
594-
if (!success) {
595-
await sendFeishuMessage(
596-
chatId,
597-
userId,
598-
t("opencode_start.start_error", { error: error || t("common.unknown_error") }),
599-
);
600-
return;
601-
}
602-
603-
const ready = await waitForServerReadyFeishu(10000);
604-
if (!ready) {
605-
await sendFeishuMessage(
606-
chatId,
607-
userId,
608-
t("opencode_start.started_not_ready", { pid: processManager.getPID() ?? "-" }),
609-
);
610-
return;
611-
}
612-
613-
const { data: health } = await opencodeClient.global.health();
614-
await sendFeishuMessage(
615-
chatId,
616-
userId,
617-
t("opencode_start.success", {
618-
pid: processManager.getPID() ?? "-",
619-
version: health?.version || t("common.unknown"),
620-
}),
621-
);
622-
623-
logger.info(`[Feishu] OpenCode server started, PID=${processManager.getPID()}`);
624-
} catch (err) {
625-
logger.error("[Feishu] Error in opencode_start command:", err);
626-
await sendFeishuMessage(chatId, userId, t("opencode_start.error"));
627-
}
628-
}
629-
630-
async function handleOpencodeStopCommand(chatId: string, userId: string): Promise<void> {
631-
try {
632-
if (!processManager.isRunning()) {
633-
try {
634-
const { data, error } = await opencodeClient.global.health();
635-
if (!error && data?.healthy) {
636-
await sendFeishuMessage(chatId, userId, t("opencode_stop.external_running"));
637-
return;
638-
}
639-
} catch {
640-
// Server not accessible
641-
}
642-
await sendFeishuMessage(chatId, userId, t("opencode_stop.not_running"));
643-
return;
644-
}
645-
646-
const pid = processManager.getPID();
647-
await sendFeishuMessage(chatId, userId, t("opencode_stop.stopping", { pid: pid ?? "-" }));
648-
649-
const { success, error } = await processManager.stop(5000);
650-
651-
if (!success) {
652-
await sendFeishuMessage(
653-
chatId,
654-
userId,
655-
t("opencode_stop.stop_error", { error: error || t("common.unknown_error") }),
656-
);
657-
return;
658-
}
659-
660-
await sendFeishuMessage(chatId, userId, t("opencode_stop.success"));
661-
logger.info("[Feishu] OpenCode server stopped");
662-
} catch (err) {
663-
logger.error("[Feishu] Error in opencode_stop command:", err);
664-
await sendFeishuMessage(chatId, userId, t("opencode_stop.error"));
665-
}
666-
}
667-
668558
async function handleHelpCommand(chatId: string, userId: string): Promise<void> {
669559
const commands = getLocalizedBotCommandsFeishu();
670560
const lines = commands.map((item) => `/${item.command} - ${item.description}`);
@@ -774,8 +664,6 @@ function getLocalizedBotCommandsFeishu(): { command: string; description: string
774664
{ command: "task", description: t("cmd.description.task") },
775665
{ command: "tasklist", description: t("cmd.description.tasklist") },
776666
{ command: "commands", description: t("cmd.description.commands") },
777-
{ command: "opencode_start", description: t("cmd.description.opencode_start") },
778-
{ command: "opencode_stop", description: t("cmd.description.opencode_stop") },
779667
{ command: "exit", description: t("cmd.description.exit") },
780668
{ command: "help", description: t("cmd.description.help") },
781669
];
@@ -796,8 +684,6 @@ function getValidCommands(): string[] {
796684
"task",
797685
"tasklist",
798686
"commands",
799-
"opencode_start",
800-
"opencode_stop",
801687
"exit",
802688
"help",
803689
];
@@ -1124,10 +1010,6 @@ function processMessage(userId: string, chatId: string, text: string, _messageId
11241010
const message = await handleCommandsCommand(chatId, userId);
11251011
await sendFeishuMessage(chatId, userId, message);
11261012
})();
1127-
} else if (text.startsWith("/opencode_start")) {
1128-
void handleOpencodeStartCommand(chatId, userId);
1129-
} else if (text.startsWith("/opencode_stop")) {
1130-
void handleOpencodeStopCommand(chatId, userId);
11311013
} else if (text.startsWith("/exit")) {
11321014
void handleExitCommand(chatId, userId);
11331015
} else if (text.startsWith("/help") || text === "help" || text === "帮助" || text === "/帮助") {

0 commit comments

Comments
 (0)