Skip to content

refactor(telegram): simplify provider delivery and auth#78762

Merged
obviyus merged 6 commits intoopenclaw:mainfrom
obviyus:telegram-provider-distill
May 7, 2026
Merged

refactor(telegram): simplify provider delivery and auth#78762
obviyus merged 6 commits intoopenclaw:mainfrom
obviyus:telegram-provider-distill

Conversation

@obviyus
Copy link
Copy Markdown
Contributor

@obviyus obviyus commented May 7, 2026

Summary

  • unify Telegram durable outbound delivery around one channel outbound adapter
  • centralize Telegram DM/command authorization helpers
  • use grammY native constants and InputFile helpers directly
  • preserve Telegram's 10-option poll cap in the unified outbound contract

Real behavior proof

Behavior or issue addressed: Telegram polls must preserve the channel-specific 10-option cap after the outbound adapter refactor, so over-limit polls fail before send instead of reaching Telegram and failing late.

Real environment tested: Local OpenClaw checkout at PR head fc2365d04a7006d38454c49df70792cf1d805b5c, real pnpm openclaw message poll CLI path, Telegram channel dry-run. Also rebuilt and restarted the WSL2 gateway from this PR stack for manual Telegram testing on ubuntu@100.79.136.128. No separate live Telegram poll send was automated from the local CLI.

Exact steps or command run after this patch: Ran /opt/homebrew/bin/bunx pnpm openclaw message poll --channel telegram --target 12345 --poll-question 'Cap proof?' --poll-option one --poll-option two --poll-option three --poll-option four --poll-option five --poll-option six --poll-option seven --poll-option eight --poll-option nine --poll-option ten --dry-run --json, then ran the same command with --poll-option eleven added. On the WSL2 box, built /home/ubuntu/openclaw-pr-78762 and restarted openclaw-gateway.service from /home/ubuntu/openclaw-pr-78762/dist/index.js gateway --port 18789.

Evidence after fix:

10-option command output included:
{
  "action": "poll",
  "channel": "telegram",
  "dryRun": true,
  "handledBy": "core",
  "payload": {
    "channel": "telegram",
    "to": "telegram:12345",
    "question": "Cap proof?",
    "options": ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"],
    "via": "gateway",
    "dryRun": true
  }
}

11-option command output:
Error: Poll supports at most 10 options
ELIFECYCLE Command failed with exit code 1.

WSL2 gateway status:
Runtime: running (pid 12531, state active, sub running, last exit 0, reason 0)
Connectivity probe: ok
Command: /usr/bin/node /home/ubuntu/openclaw-pr-78762/dist/index.js gateway --port 18789

Observed result after fix: The real CLI dry-run accepted exactly 10 Telegram poll options and rejected 11 options before send with Poll supports at most 10 options; the WSL2 Telegram gateway restarted from the PR build and reported a healthy connectivity probe.

What was not tested: Automated live Telegram API poll send from local CLI; WSL2 gateway was left running for maintainer manual Telegram testing.

Verification

  • /opt/homebrew/bin/bunx pnpm test extensions/telegram/src/telegram-outbound.test.ts extensions/telegram/src/outbound-adapter.test.ts extensions/telegram/src/bot-message-context.reactions.test.ts extensions/telegram/src/bot-message-context.dm-threads.test.ts extensions/telegram/src/bot-message-context.thread-binding.test.ts extensions/telegram/src/bot-message-context.require-mention.test.ts extensions/telegram/src/bot-native-commands.test.ts extensions/telegram/src/bot-native-commands.group-auth.test.ts extensions/telegram/src/bot-native-commands.skills-allowlist.test.ts extensions/telegram/src/bot-handlers.runtime.test.ts extensions/telegram/src/group-access.base-access.test.ts extensions/telegram/src/dm-access.test.ts -- --reporter=verbose
  • /opt/homebrew/bin/bunx pnpm check:changed
  • /opt/homebrew/bin/bunx pnpm openclaw message poll --channel telegram --target 12345 --poll-question 'Cap proof?' --poll-option one --poll-option two --poll-option three --poll-option four --poll-option five --poll-option six --poll-option seven --poll-option eight --poll-option nine --poll-option ten --dry-run --json
  • /opt/homebrew/bin/bunx pnpm openclaw message poll --channel telegram --target 12345 --poll-question 'Cap proof?' --poll-option one --poll-option two --poll-option three --poll-option four --poll-option five --poll-option six --poll-option seven --poll-option eight --poll-option nine --poll-option ten --poll-option eleven --dry-run --json (expected failure)

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: XL maintainer Maintainer-authored PR labels May 7, 2026
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented May 7, 2026

Codex review: needs maintainer review before merge.

Summary
This PR consolidates Telegram outbound sends and polls into one outbound adapter, centralizes Telegram DM/command authorization helpers, and replaces local grammY fallbacks with native API_CONSTANTS and InputFile usage.

Reproducibility: not applicable. this is a refactor PR rather than a bug report. The prior poll-cap concern is covered at PR head by pollMaxOptions: 10 plus the real CLI dry-run proof.

Real behavior proof
Sufficient (live_output): The PR body includes copied after-fix terminal output from a real OpenClaw CLI dry-run path, and the GitHub real-behavior-proof check is green.

Next step before merge
No narrow repair-worker defect found; the remaining action is maintainer review and merge coordination for a broad protected Telegram refactor.

Security
Cleared: No security or supply-chain concern found; the diff refactors Telegram plugin code/tests and uses existing grammY exports without workflow, dependency, secret, or package-resolution changes.

Review details

Best possible solution:

Have a maintainer review and land the refactor if they want the adapter/auth consolidation, preserving the restored poll cap and coordinating with overlapping Telegram outbound work.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this is a refactor PR rather than a bug report. The prior poll-cap concern is covered at PR head by pollMaxOptions: 10 plus the real CLI dry-run proof.

Is this the best way to solve the issue?

Likely yes: using the existing channel outbound adapter and command-auth seams is the maintainable direction, and I found no line-level blocker. Final landing still needs maintainer ownership because this is broad Telegram refactor work.

What I checked:

  • live_pr_state: GitHub API reports this PR is open, non-draft, mergeable with mergeable_state=clean, and still carries the protected maintainer label. (33951854b878)
  • diff_surface: The PR changes 12 Telegram plugin files, including outbound, channel registration, auth helpers, and Telegram tests. (extensions/telegram/src/channel.ts:163, 33951854b878)
  • poll_cap_preserved: PR head keeps Telegram poll validation at the channel-specific 10-option cap and wires poll duration/anonymous support through the new adapter. (extensions/telegram/src/outbound-adapter.ts:199, 33951854b878)
  • current_main_contract: Current main already exposes Telegram pollMaxOptions: 10 from the old outbound base adapter, so preserving that contract is the key regression check for this refactor. (extensions/telegram/src/outbound-base.ts:9, be33b68fd4a0)
  • real_behavior_proof: The PR body now includes copied terminal output from the real pnpm openclaw message poll --channel telegram ... --dry-run --json path showing 10 options accepted and 11 rejected, and the GitHub Real behavior proof check is successful. (33951854b878)
  • ci_status: Check-runs for the head SHA show the main check, channel, lint, type, security, and build-smoke jobs completed successfully; CodeQL is neutral and unrelated skipped jobs remain skipped. (33951854b878)

Likely related people:

  • steipete: Recent merged work moved bundled plugins to the message lifecycle and touched Telegram channel/outbound paths that this PR rewrites. (role: recent maintainer; confidence: high; commits: 05eda57b3c72, 1dd9a15eb850; files: extensions/telegram/src/channel.ts, extensions/telegram/src/outbound-adapter.ts, extensions/telegram/src/outbound-base.ts)
  • vincentkoc: Recent merged Telegram outbound work changed interactive delivery behavior in the adapter area affected by this refactor. (role: recent adjacent maintainer; confidence: medium; commits: 6776129315e9; files: extensions/telegram/src/outbound-adapter.ts)
  • obviyus: Although this person authored this PR, they also appear in prior merged Telegram/channel history for polling startup behavior. (role: adjacent owner; confidence: medium; commits: 5b94c4ce9396; files: extensions/telegram/src/channel.ts)

Remaining risk / open question:

  • No live Telegram API send or auth session is attached; the accepted proof covers the real CLI dry-run poll-cap path while the broader auth/refactor behavior remains covered by tests and CI.
  • Open fix(telegram): expose provider-accepted outbound delivery #78261 overlaps Telegram outbound adapter/channel files and should be coordinated before landing.

Codex review notes: model gpt-5.5, reasoning high; reviewed against be33b68fd4a0.

@obviyus obviyus force-pushed the telegram-provider-distill branch from e6a8f62 to 98c7060 Compare May 7, 2026 12:10
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 7, 2026
@obviyus obviyus force-pushed the telegram-provider-distill branch from 3395185 to fc2365d Compare May 7, 2026 13:31
@obviyus obviyus merged commit 238e72d into openclaw:main May 7, 2026
86 of 87 checks passed
@obviyus
Copy link
Copy Markdown
Contributor Author

obviyus commented May 7, 2026

Landed via rebase onto main.

  • Scoped tests: /opt/homebrew/bin/bunx pnpm test extensions/telegram/src/telegram-outbound.test.ts extensions/telegram/src/outbound-adapter.test.ts extensions/telegram/src/bot-message-context.reactions.test.ts extensions/telegram/src/bot-message-context.dm-threads.test.ts extensions/telegram/src/bot-message-context.thread-binding.test.ts extensions/telegram/src/bot-message-context.require-mention.test.ts extensions/telegram/src/bot-native-commands.test.ts extensions/telegram/src/bot-native-commands.group-auth.test.ts extensions/telegram/src/bot-native-commands.skills-allowlist.test.ts extensions/telegram/src/bot-handlers.runtime.test.ts extensions/telegram/src/group-access.base-access.test.ts extensions/telegram/src/dm-access.test.ts -- --reporter=verbose; /opt/homebrew/bin/bunx pnpm check:changed; Telegram poll dry-run accepted 10 options and rejected 11 with Poll supports at most 10 options; WSL2 gateway rebuilt/restarted from the PR worktree with a healthy connectivity probe.
  • Changelog: CHANGELOG.md updated.
  • Land commit: fc2365d
  • Merge commit: 238e72d

Thanks @obviyus!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram maintainer Maintainer-authored PR proof: sufficient ClawSweeper judged the real behavior proof convincing. size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant