Skip to content

fix: handle telegram: prefix in resolveTelegramTargetChatType#1072

Closed
danielz1z wants to merge 1 commit intoopenclaw:mainfrom
danielz1z:fix/telegram-inline-buttons-dm-scope
Closed

fix: handle telegram: prefix in resolveTelegramTargetChatType#1072
danielz1z wants to merge 1 commit intoopenclaw:mainfrom
danielz1z:fix/telegram-inline-buttons-dm-scope

Conversation

@danielz1z
Copy link
Copy Markdown
Contributor

When using inlineButtons="dm" or "group" scope, the validation in resolveTelegramTargetChatType() fails for numeric chat IDs.

Root cause: normalizeTelegramMessagingTarget() adds a telegram: prefix during target resolution:

  • Input: "5232990709"
  • After normalization: "telegram:5232990709"

But resolveTelegramTargetChatType() expects a pure numeric string and its regex /^-?\d+$/ fails on the prefixed value.

Error seen:

Telegram inline buttons require a numeric chat id when inlineButtons="dm".

Fix: Strip the telegram: prefix before checking the numeric pattern.

Tests: Added test file for resolveTelegramTargetChatType covering:

  • Positive numeric IDs (DMs)
  • Negative numeric IDs (groups)
  • Prefixed targets (telegram:xxx)
  • Usernames
  • Empty strings

When using inlineButtons="dm" or "group" scope, the validation check
resolveTelegramTargetChatType() failed for numeric chat IDs because
normalizeTelegramMessagingTarget() adds a "telegram:" prefix during
target resolution.

For example, target "5232990709" becomes "telegram:5232990709" after
normalization, but the regex /^-?\d+$/ expects a pure numeric string.

The fix strips the telegram: prefix before checking the numeric pattern.

Adds tests for resolveTelegramTargetChatType with various input formats.
@steipete steipete self-assigned this Jan 17, 2026
steipete added a commit that referenced this pull request Jan 17, 2026
@danielz1z

Co-authored-by: danielz1z <danielz1z@users.noreply.github.com>
@steipete steipete closed this Jan 17, 2026
@steipete
Copy link
Copy Markdown
Contributor

Thanks @danielz1z! Landed on main via d63cc1e.

What I did:

Tests:

  • pnpm lint (pass)
  • pnpm test (pass)
  • pnpm build (fails: src/media-understanding/attachments.ts TS2322 "document" not assignable to union)

steipete added a commit that referenced this pull request Jan 17, 2026
…nielz1z

Co-authored-by: danielz1z <danielz1z@users.noreply.github.com>
@steipete
Copy link
Copy Markdown
Contributor

Added extra tests post-merge to cover tg/group/topic inline button targets.

Commit: f3f8050
Tests: pnpm test -- src/agents/tools/telegram-actions.test.ts (vitest ran full suite)

zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
… — thanks @danielz1z

Co-authored-by: danielz1z <danielz1z@users.noreply.github.com>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…anks @danielz1z

Co-authored-by: danielz1z <danielz1z@users.noreply.github.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.

2 participants