Skip to content

Fix: add tg send command in cli#149

Open
wjc1207 wants to merge 1 commit intomemovai:mainfrom
wjc1207:fix/cli
Open

Fix: add tg send command in cli#149
wjc1207 wants to merge 1 commit intomemovai:mainfrom
wjc1207:fix/cli

Conversation

@wjc1207
Copy link
Copy Markdown
Contributor

@wjc1207 wjc1207 commented Mar 14, 2026

Fix: add tg send command in cli

Summary by CodeRabbit

  • New Features
    • Added a Telegram send command to the serial CLI, enabling users to send messages directly through the command interface with specified chat ID and message text.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 14, 2026

📝 Walkthrough

Walkthrough

A new Telegram send command (tg_send) is added to the serial CLI. The implementation includes a tg_send_args structure with chat_id and text parameters, a cmd_tg_send handler function that parses arguments and invokes telegram_send_message, and command registration during CLI initialization.

Changes

Cohort / File(s) Summary
Telegram CLI Command Addition
main/cli/serial_cli.c
Adds tg_send command with argument structure (chat_id, text), handler function (cmd_tg_send) that parses arguments and calls telegram_send_message, and CLI command registration with initialization.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A message bounces through the wire,
From CLI to Telegram's fire,
Chat IDs and text take flight,
The tg_send command shines so bright,
No more silent, we speak aloud! 📬✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding a new 'tg send' command to the CLI as shown in the code additions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use OpenGrep to find security vulnerabilities and bugs across 17+ programming languages.

OpenGrep is compatible with Semgrep configurations. Add an opengrep.yml or semgrep.yml configuration file to your project to enable OpenGrep analysis.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
main/cli/serial_cli.c (1)

86-98: Prefer async execution with timeout for tg_send.

Line 94 performs a synchronous network send on the CLI path. If Telegram/API is slow, the REPL can block noticeably. Consider mirroring the cmd_web_search worker-task + timeout pattern for better CLI responsiveness.

Proposed direction (same pattern as cmd_web_search)
 static int cmd_tg_send(int argc, char **argv)
 {
@@
-    esp_err_t err = telegram_send_message(tg_send_args.chat_id->sval[0],
-                                         tg_send_args.text->sval[0]);
+    /* run send in a worker task + wait with timeout */
+    esp_err_t err = run_tg_send_with_timeout(
+        tg_send_args.chat_id->sval[0],
+        tg_send_args.text->sval[0],
+        pdMS_TO_TICKS(15000));
     printf("tg_send status: %s\n", esp_err_to_name(err));
     return (err == ESP_OK) ? 0 : 1;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@main/cli/serial_cli.c` around lines 86 - 98, Replace the synchronous
telegram_send_message call in cmd_tg_send with the same worker-task + timeout
pattern used by cmd_web_search: spawn a short-lived worker (e.g.,
tg_send_worker) that calls telegram_send_message using
tg_send_args.chat_id->sval[0] and tg_send_args.text->sval[0], have the worker
post the esp_err_t result back via a queue or semaphore, and have cmd_tg_send
wait for that result with a bounded timeout (e.g., 5s); on timeout log a clear
timeout/error and return non-zero, otherwise print esp_err_to_name(result) and
return 0 on ESP_OK. Ensure you clean up the worker and synchronization primitive
the same way cmd_web_search does.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@main/cli/serial_cli.c`:
- Around line 86-98: Replace the synchronous telegram_send_message call in
cmd_tg_send with the same worker-task + timeout pattern used by cmd_web_search:
spawn a short-lived worker (e.g., tg_send_worker) that calls
telegram_send_message using tg_send_args.chat_id->sval[0] and
tg_send_args.text->sval[0], have the worker post the esp_err_t result back via a
queue or semaphore, and have cmd_tg_send wait for that result with a bounded
timeout (e.g., 5s); on timeout log a clear timeout/error and return non-zero,
otherwise print esp_err_to_name(result) and return 0 on ESP_OK. Ensure you clean
up the worker and synchronization primitive the same way cmd_web_search does.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a45b5347-0f1b-4510-aa05-067afe4f44ab

📥 Commits

Reviewing files that changed from the base of the PR and between 5ff0920 and 785ec45.

📒 Files selected for processing (1)
  • main/cli/serial_cli.c

@IRONICBo IRONICBo self-assigned this Mar 15, 2026
@IRONICBo IRONICBo self-requested a review March 15, 2026 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants