diff --git a/main/cli/serial_cli.c b/main/cli/serial_cli.c index 4ac76a9..f8b8aae 100644 --- a/main/cli/serial_cli.c +++ b/main/cli/serial_cli.c @@ -1,7 +1,8 @@ #include "serial_cli.h" #include "mimi_config.h" #include "wifi/wifi_manager.h" -#include "telegram/telegram_bot.h" +#include "channels/telegram/telegram_bot.h" +#include "channels/feishu/feishu_bot.h" #include "llm/llm_proxy.h" #include "memory/memory_store.h" #include "memory/session_mgr.h" @@ -72,6 +73,26 @@ static int cmd_set_tg_token(int argc, char **argv) return 0; } +/* --- set_feishu_creds command --- */ +static struct { + struct arg_str *app_id; + struct arg_str *app_secret; + struct arg_end *end; +} feishu_creds_args; + +static int cmd_set_feishu_creds(int argc, char **argv) +{ + int nerrors = arg_parse(argc, argv, (void **)&feishu_creds_args); + if (nerrors != 0) { + arg_print_errors(stderr, feishu_creds_args.end, argv[0]); + return 1; + } + feishu_set_credentials(feishu_creds_args.app_id->sval[0], + feishu_creds_args.app_secret->sval[0]); + printf("Feishu credentials saved.\n"); + return 0; +} + /* --- set_api_key command --- */ static struct { struct arg_str *key; @@ -619,6 +640,18 @@ esp_err_t serial_cli_init(void) }; esp_console_cmd_register(&tg_token_cmd); + /* set_feishu_creds */ + feishu_creds_args.app_id = arg_str1(NULL, NULL, "", "Feishu App ID"); + feishu_creds_args.app_secret = arg_str1(NULL, NULL, "", "Feishu App Secret"); + feishu_creds_args.end = arg_end(2); + esp_console_cmd_t feishu_creds_cmd = { + .command = "set_feishu_creds", + .help = "Set Feishu app credentials (app_id app_secret)", + .func = &cmd_set_feishu_creds, + .argtable = &feishu_creds_args, + }; + esp_console_cmd_register(&feishu_creds_cmd); + /* set_api_key */ api_key_args.key = arg_str1(NULL, NULL, "", "LLM API key"); api_key_args.end = arg_end(1); diff --git a/main/mimi.c b/main/mimi.c index 2d927cc..0e8e8fa 100644 --- a/main/mimi.c +++ b/main/mimi.c @@ -12,7 +12,8 @@ #include "mimi_config.h" #include "bus/message_bus.h" #include "wifi/wifi_manager.h" -#include "telegram/telegram_bot.h" +#include "channels/telegram/telegram_bot.h" +#include "channels/feishu/feishu_bot.h" #include "llm/llm_proxy.h" #include "agent/agent_loop.h" #include "memory/memory_store.h" @@ -78,6 +79,13 @@ static void outbound_dispatch_task(void *arg) } else { ESP_LOGI(TAG, "Telegram send success for %s (%d bytes)", msg.chat_id, (int)strlen(msg.content)); } + } else if (strcmp(msg.channel, MIMI_CHAN_FEISHU) == 0) { + esp_err_t send_err = feishu_send_message(msg.chat_id, msg.content); + if (send_err != ESP_OK) { + ESP_LOGE(TAG, "Feishu send failed for %s: %s", msg.chat_id, esp_err_to_name(send_err)); + } else { + ESP_LOGI(TAG, "Feishu send success for %s (%d bytes)", msg.chat_id, (int)strlen(msg.content)); + } } else if (strcmp(msg.channel, MIMI_CHAN_WEBSOCKET) == 0) { esp_err_t ws_err = ws_server_send(msg.chat_id, msg.content); if (ws_err != ESP_OK) { @@ -121,6 +129,7 @@ void app_main(void) ESP_ERROR_CHECK(wifi_manager_init()); ESP_ERROR_CHECK(http_proxy_init()); ESP_ERROR_CHECK(telegram_bot_init()); + ESP_ERROR_CHECK(feishu_bot_init()); ESP_ERROR_CHECK(llm_proxy_init()); ESP_ERROR_CHECK(tool_registry_init()); ESP_ERROR_CHECK(cron_service_init()); @@ -149,6 +158,7 @@ void app_main(void) /* Start network-dependent services */ ESP_ERROR_CHECK(agent_loop_start()); ESP_ERROR_CHECK(telegram_bot_start()); + ESP_ERROR_CHECK(feishu_bot_start()); cron_service_start(); heartbeat_start(); ESP_ERROR_CHECK(ws_server_start());