@@ -1,5 +1,6 @@
|
||||
#include "tools/tool_cron.h"
|
||||
#include "cron/cron_service.h"
|
||||
#include "bus/message_bus.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
@@ -45,6 +46,14 @@ esp_err_t tool_cron_add_execute(const char *input_json, char *output, size_t out
|
||||
if (channel) strncpy(job.channel, channel, sizeof(job.channel) - 1);
|
||||
if (chat_id) strncpy(job.chat_id, chat_id, sizeof(job.chat_id) - 1);
|
||||
|
||||
if (strcmp(job.channel, MIMI_CHAN_TELEGRAM) == 0 &&
|
||||
(job.chat_id[0] == '\0' || strcmp(job.chat_id, "cron") == 0)) {
|
||||
snprintf(output, output_size,
|
||||
"Error: cron_add with channel='telegram' requires a valid chat_id");
|
||||
cJSON_Delete(root);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (strcmp(schedule_type, "every") == 0) {
|
||||
job.kind = CRON_KIND_EVERY;
|
||||
cJSON *interval = cJSON_GetObjectItem(root, "interval_s");
|
||||
|
||||
@@ -143,8 +143,8 @@ esp_err_t tool_registry_init(void)
|
||||
"\"interval_s\":{\"type\":\"integer\",\"description\":\"Interval in seconds (required for 'every')\"},"
|
||||
"\"at_epoch\":{\"type\":\"integer\",\"description\":\"Unix timestamp to fire at (required for 'at')\"},"
|
||||
"\"message\":{\"type\":\"string\",\"description\":\"Message to inject when the job fires, triggering an agent turn\"},"
|
||||
"\"channel\":{\"type\":\"string\",\"description\":\"Optional reply channel (e.g. 'telegram'). Defaults to 'system'\"},"
|
||||
"\"chat_id\":{\"type\":\"string\",\"description\":\"Optional reply chat_id. Defaults to 'cron'\"}"
|
||||
"\"channel\":{\"type\":\"string\",\"description\":\"Optional reply channel (e.g. 'telegram'). If omitted, current turn channel is used when available\"},"
|
||||
"\"chat_id\":{\"type\":\"string\",\"description\":\"Optional reply chat_id. Required when channel='telegram'. If omitted during a Telegram turn, current chat_id is used\"}"
|
||||
"},"
|
||||
"\"required\":[\"name\",\"schedule_type\",\"message\"]}",
|
||||
.execute = tool_cron_add_execute,
|
||||
|
||||
Reference in New Issue
Block a user