Skip to content

fix(cron): support Telegram topic/thread ID in delivery target#474

Closed
mitschabaude-bot wants to merge 1 commit intoopenclaw:mainfrom
mitschabaude-bot:fix/cron-telegram-topic-delivery
Closed

fix(cron): support Telegram topic/thread ID in delivery target#474
mitschabaude-bot wants to merge 1 commit intoopenclaw:mainfrom
mitschabaude-bot:fix/cron-telegram-topic-delivery

Conversation

@mitschabaude-bot
Copy link
Contributor

Summary

When delivering cron job output to Telegram, the to field now supports specifying a topic (forum thread) ID in addition to the chat ID.

Problem

Cron jobs configured to deliver to Telegram groups with forum topics always sent messages to the main/general topic, even when a topic ID was specified in the to field. The topic portion was not being parsed, and messageThreadId was not passed to the send function.

Solution

Added a parseTelegramTarget() helper that extracts both chatId and optional topicId from the delivery target string.

Supported formats:

  • chatId — plain chat ID or @username
  • chatId:topicId — chat ID with numeric topic ID (e.g., -1001234567890:123)
  • chatId:topic:topicId — alternative format with explicit marker

The parsed topicId is then passed as messageThreadId to sendMessageTelegram().

Testing

  • Added unit tests for parseTelegramTarget() covering all formats
  • All existing tests pass

When delivering cron job output to Telegram, the 'to' field now supports
specifying a topic (forum thread) ID in addition to the chat ID.

Supported formats:
- chatId (plain chat ID or @username)
- chatId:topicId (chat ID with numeric topic ID)
- chatId:topic:topicId (alternative format with explicit marker)

This enables cron jobs to deliver messages to specific forum topics
rather than always going to the main/general topic.

Adds parseTelegramTarget helper function with unit tests.
@steipete steipete self-assigned this Jan 8, 2026
@steipete
Copy link
Contributor

steipete commented Jan 8, 2026

thanks!

@mitschabaude
Copy link

context: I follow this TG channel pattern: https://x.com/nachoiacovino/status/2008571909584392547

asked my clawd to notify me on heartbeats, but it ended up posting in the general channel instead of the dedicated one

@steipete
Copy link
Contributor

steipete commented Jan 8, 2026

Nice fix + tests. One big bug though: cron often uses lastTo like telegram:123 (see normalizeChatId() comment). Current parseTelegramTarget() treats that as chatId="telegram", topicId=123 → send goes to @telegram.\n\nSuggested tweak: strip common internal prefixes before parsing topic suffix, e.g.\n\nconst raw = to.trim(); const normalized = raw.replace(/^(telegram|tg|group):/i, "").trim();\nthen run the :topic: / :(\d+) parsing on normalized.\n\nTests to add: parseTelegramTarget("telegram:123") -> { chatId: "123" }, parseTelegramTarget("telegram:group:-100...:topic:456") -> { chatId: "group:-100...", topicId: 456 } (or strip group too).\n\nMinor: chatId:topicId alias is fine, but chatId:topic:topicId seems like the canonical format already used elsewhere.

@steipete
Copy link
Contributor

steipete commented Jan 8, 2026

Landed on main (with fixes) — thanks @mitschabaude-bot!\n\n- Preserved original author in git graph: 2afb75d (cherry-pick of 24a6595)\n- Fix: handle internal prefixes like telegram:123 + telegram:group:... before parsing topic suffixes: 5fea53d\n- Formatting: 58a9e35\n\nChangelog updated too.

@steipete steipete closed this Jan 8, 2026
ashiabbott pushed a commit to ashiabbott/openclaw that referenced this pull request Feb 20, 2026
…eway

Replace bare KeepAlive=true with { SuccessfulExit: true } in the
LaunchAgent plist. This makes launchd only restart the gateway on a
crash exit, not when it is intentionally stopped by the App's
GatewayLaunchAgentManager or by a kickstart -k call.

Also add ThrottleInterval=5 to prevent exponential backoff from
compressing rapid crash/restart cycles.

Audit changes:
- launchd-keep-alive now flags any plist that does NOT have the
  KeepAlive { SuccessfulExit: true } dict form (including old true plists)
- New launchd-throttle-interval audit code flags plists missing
  ThrottleInterval=5

Tests (28 pass):
- buildLaunchAgentPlist produces SuccessfulExit dict + ThrottleInterval=5
- installLaunchAgent writes plist with new KeepAlive form
- auditGatewayServiceConfig (darwin) flags legacy KeepAlive=true + missing
  ThrottleInterval as issues
- auditGatewayServiceConfig (darwin) accepts new-format plists cleanly

Closes openclaw#20257 (migrated as Workshop task openclaw#474)
heatherstew44-maker pushed a commit to heatherstew44-maker/openclaw that referenced this pull request Mar 8, 2026
* Add Russian language

* Add Russian language

* Clean up hidden Unicode characters in Russian translation

* add languages.ts

* add some missing translations

---------

Co-authored-by: CJ Pais <cj@cjpais.com>
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.

3 participants