openclaw/src/telegram
nicolasstanley 4a5e9f0a4f
fix(telegram): accept messages from group members in allowlisted groups (#9775)
* fix(telegram): accept messages from group members in allowlisted groups

Issue #4559: Telegram bot was silently dropping messages from non-paired users
in allowlisted group chats due to overly strict sender filtering.

The fix adds a check to distinguish between:
1. Group itself is allowlisted → accept messages from any member
2. Group is NOT allowlisted → only accept from allowlisted senders

Changes:
- Check if group ID is in the allowlist (or allowlist is wildcard)
- Only reject sender if they're not in allowlist AND group is not allowlisted
- Improved logging to indicate the actual reason for rejection

This preserves security controls while fixing the UX issue where group members
couldn't participate unless individually allowlisted.

Backwards compatible: existing allowlists continue to work as before.

* style: format telegram fix for oxfmt compliance

* refactor(telegram): clarify group allowlist semantics in fix for #4559

Changes:
- Rename 'isGroupInAllowlist' to 'isGroupChatIdInAllowlist' for clarity
- Expand comments to explain the semantic distinction:
  * Group chat ID in allowlist -> accept any group member (fixes #4559)
  * Group chat ID NOT in allowlist -> enforce sender allowlist (preserves security)
- This addresses concerns about config semantics raised in code review

The fix maintains backward compatibility:
- 'groupAllowFrom' with group chat IDs now correctly acts as group enablement
- 'groupAllowFrom' with sender IDs continues to work as sender allowlist
- Operators should use group chat IDs for group enablement, sender IDs for sender control

Note: If operators were using 'groupAllowFrom' with group IDs expecting sender-level
filtering, they should migrate to a separate sender allowlist config. This is the
intended behavior per issue #4559.

* Telegram: allow per-group groupPolicy overrides

* Telegram: support per-group groupPolicy overrides (#9775) (thanks @nicolasstanley)

---------

Co-authored-by: George Pickett <gpickett00@gmail.com>
2026-02-05 14:45:45 -08:00
..
bot fix(telegram): pass parentPeer for forum topic binding inheritance (#9789) 2026-02-05 18:25:03 +00:00
accounts.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
accounts.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
allowed-updates.ts fix: refine telegram reactions (#964) (thanks @bohdanpodvirnyi) 2026-01-15 17:20:17 +00:00
api-logging.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
audit.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
audit.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
bot-access.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
bot-handlers.ts fix(telegram): accept messages from group members in allowlisted groups (#9775) 2026-02-05 14:45:45 -08:00
bot-message-context.dm-threads.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
bot-message-context.dm-topic-threadid.test.ts test(telegram): add DM topic threadId deliveryContext test for #8891 2026-02-05 15:33:30 +05:30
bot-message-context.sender-prefix.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
bot-message-context.ts fix(telegram): pass parentPeer for forum topic binding inheritance (#9789) 2026-02-05 18:25:03 +00:00
bot-message-dispatch.test.ts feat: per-channel responsePrefix override (#9001) 2026-02-04 16:16:34 -05:00
bot-message-dispatch.ts Telegram: remove @ts-nocheck from bot.ts, fix duplicate error handler, harden sticker caching (#9077) 2026-02-04 22:35:51 +00:00
bot-message.test.ts fix: emit diagnostics across channels 2026-01-21 00:30:34 +00:00
bot-message.ts Telegram: remove @ts-nocheck from bot-message.ts (#9180) 2026-02-05 00:20:44 +00:00
bot-native-commands.plugin-auth.test.ts refactor: use shared pairing store for telegram 2026-02-01 15:22:37 +05:30
bot-native-commands.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
bot-native-commands.ts fix(telegram): pass parentPeer for forum topic binding inheritance (#9789) 2026-02-05 18:25:03 +00:00
bot-updates.ts Telegram: use Grammy types directly, add typed Probe/Audit to plugin interface (#8403) 2026-02-04 10:09:28 +00:00
bot.create-telegram-bot.accepts-group-messages-mentionpatterns-match-without-botusername.test.ts test: speed up telegram suites 2026-02-01 22:23:16 +00:00
bot.create-telegram-bot.applies-topic-skill-filters-system-prompts.test.ts test: speed up telegram suites 2026-02-01 22:23:16 +00:00
bot.create-telegram-bot.blocks-all-group-messages-grouppolicy-is.test.ts test: speed up telegram suites 2026-02-01 22:23:16 +00:00
bot.create-telegram-bot.dedupes-duplicate-callback-query-updates-by-update.test.ts test: speed up telegram suites 2026-02-01 22:23:16 +00:00
bot.create-telegram-bot.installs-grammy-throttler.test.ts test: speed up telegram suites 2026-02-01 22:23:16 +00:00
bot.create-telegram-bot.matches-tg-prefixed-allowfrom-entries-case-insensitively.test.ts test: speed up telegram suites 2026-02-01 22:23:16 +00:00
bot.create-telegram-bot.matches-usernames-case-insensitively-grouppolicy-is.test.ts test: speed up telegram suites 2026-02-01 22:23:16 +00:00
bot.create-telegram-bot.routes-dms-by-telegram-accountid-binding.test.ts fix(telegram): pass parentPeer for forum topic binding inheritance (#9789) 2026-02-05 18:25:03 +00:00
bot.create-telegram-bot.sends-replies-without-native-reply-threading.test.ts test: speed up telegram suites 2026-02-01 22:23:16 +00:00
bot.media.downloads-media-file-path-no-file-download.test.ts Channels: finish Feishu/Lark integration 2026-02-03 14:27:39 -08:00
bot.media.includes-location-text-ctx-fields-pins.test.ts refactor: use shared pairing store for telegram 2026-02-01 15:22:37 +05:30
bot.test.ts fix(telegram): accept messages from group members in allowlisted groups (#9775) 2026-02-05 14:45:45 -08:00
bot.ts fix(telegram): pass parentPeer for forum topic binding inheritance (#9789) 2026-02-05 18:25:03 +00:00
caption.ts refactor: share telegram caption splitting 2026-01-17 03:50:09 +00:00
download.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
download.ts fix(telegram): add timeout to file download to prevent DoS (CWE-400) 2026-02-02 13:39:39 +05:30
draft-chunking.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
draft-chunking.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
draft-stream.test.ts chore: Enable `typescript/no-explicit-any` rule. 2026-02-02 16:18:09 +09:00
draft-stream.ts fix: require thread specs for telegram sends 2026-02-02 09:26:59 +05:30
fetch.test.ts refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
fetch.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
format.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
format.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
group-migration.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
group-migration.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
index.ts feat: unify provider reaction tools 2026-01-07 04:16:39 +01:00
inline-buttons.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
inline-buttons.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
model-buttons.test.ts Telegram: fix model button review issues 2026-02-04 09:23:17 +05:30
model-buttons.ts Telegram: fix model button review issues 2026-02-04 09:23:17 +05:30
monitor.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
monitor.ts fix(telegram): handle Grammy HttpError network failures (#3815) (#7195) 2026-02-02 15:25:41 +00:00
network-config.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
network-config.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
network-errors.test.ts fix(telegram): recover from grammY "timed out" long-poll errors (#7239) 2026-02-02 22:37:22 +00:00
network-errors.ts fix(telegram): recover from grammY "timed out" long-poll errors (#7239) 2026-02-02 22:37:22 +00:00
probe.ts fix: normalize gateway dev mode detection 2026-01-18 01:08:47 +00:00
proxy.test.ts fix: honor Telegram proxy dispatcher (#4456) (thanks @spiceoogway) 2026-01-30 14:38:39 +05:30
proxy.ts fix: align proxy fetch typing 2026-02-04 04:09:53 -08:00
reaction-level.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
reaction-level.ts refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
send.caption-split.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
send.edit-message.test.ts feat(telegram): add edit message action (#2394) (thanks @marcelomar21) 2026-01-26 15:34:47 -08:00
send.preserves-thread-params-plain-text-fallback.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
send.proxy.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
send.returns-undefined-empty-input.test.ts test: speed up telegram suites 2026-02-01 22:23:16 +00:00
send.ts fix: require thread specs for telegram sends 2026-02-02 09:26:59 +05:30
sent-message-cache.test.ts fix: lint errors 2026-01-15 17:07:38 +00:00
sent-message-cache.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
sticker-cache.test.ts refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
sticker-cache.ts feat: add Claude Opus 4.6 to built-in model catalog (#9853) 2026-02-05 12:09:23 -08:00
targets.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
targets.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
token.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
token.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
update-offset-store.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
update-offset-store.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
voice.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
voice.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
webhook-set.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
webhook.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
webhook.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00