You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c7e49ad
Browse filesBrowse the repository at this point in the historyBrowse files
feat(onboard): support Telegram mention-only mode (#2417)
## Summary
Parity with Discord's existing `requireMention` toggle, scoped to
Telegram. Teams running the bot in busy Telegram groups can now restrict
it to reply only when @mentioned instead of to every group message.
## Problem
Telegram's group behavior in NemoClaw is hardcoded to `groupPolicy:
open` — the bot answers every message the moment it joins a group. Users
have no CLI flag, env var, or onboard prompt to narrow this; the only
workaround is hand-patching `openclaw.json` after build.
Discord already has the equivalent via `requireMention`.
## Changes
- **[`src/lib/sandbox-channels.ts`](src/lib/sandbox-channels.ts)** — add
`requireMentionEnvKey: \"TELEGRAM_REQUIRE_MENTION\"` + help string to
the Telegram `ChannelDef`.
- **[`src/lib/onboard.ts`](src/lib/onboard.ts)** — loosen the
interactive mention-prompt gate: the prompt used to require both
`requireMentionEnvKey` AND a populated `serverIdEnvKey`
(Discord-specific). Now any channel with `requireMentionEnvKey` fires
the prompt, with the Discord-specific server-ID check preserved. Also
build a `telegramConfig` from `TELEGRAM_REQUIRE_MENTION` and pass it
through `patchStagedDockerfile`.
- **[`Dockerfile`](Dockerfile)** — add `ARG
NEMOCLAW_TELEGRAM_CONFIG_B64=e30=`, promote to ENV, and wire into the
Python openclaw.json generator: \`\`groupPolicy\`\` becomes
\`\`mentions\`\` when \`\`requireMention\`\` is truthy, otherwise
\`\`open\`\` (existing default preserved).
## Usage
**Interactive:**
```
[5/8] Messaging channels
...
✓ telegram token saved
Reply only when @mentioned? [Y/n]
```
**Non-interactive:**
```bash
TELEGRAM_REQUIRE_MENTION=1 nemoclaw onboard --non-interactive
```
Unset env + non-interactive = same as before (open groups). No behavior
change for existing scripted onboards.
## Test plan
- [x] `npx vitest run test/onboard.test.ts
src/lib/sandbox-channels.test.ts test/onboard-selection.test.ts` — 179
tests pass including 3 new ones:
- \`#1737: patches the staged Dockerfile with Telegram mention-only
config\` — round-trips \`{\"requireMention\": true}\`.
- \`#1737: patches the staged Dockerfile with Telegram open-group config
when requireMention=false\` — explicit \`false\` round-trips.
- \`#1737: preserves default Telegram group-open behavior when
telegramConfig is empty\` — backward compat: ARG default \`e30=\` is not
rewritten when the caller passes \`{}\`.
- [x] Typecheck clean.
- [x] Existing Discord guild + messaging-channels tests unchanged and
green.
## Prior art
Closed PR [#1784](#1784) by
@kagura-agent proposed the same approach and was thanked by @wscurran
with CodeRabbit review addressed before the author voluntarily closed
\"to reduce PR volume.\" This PR takes the same shape with a refreshed
test layout and an explicit backward-compat regression test.
Fixes#1737.
Signed-off-by: latenighthackathon
<[email protected]>
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Configurable Telegram "mention-only" mode added as a build/runtime
input and passed into the running environment.
* Container now accepts an encoded Telegram config and uses it to set
the channel policy instead of a fixed default.
* Onboarding records Telegram mention preference, triggers sandbox
recreation when it changes, and channel setup prompts respect
mention-only controls.
* **Tests**
* Added unit tests for config injection, session persistence,
validation, and compatibility.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: latenighthackathon <[email protected]>
Co-authored-by: latenighthackathon <[email protected]>
Co-authored-by: cjagwani <[email protected]>
userIdHelp: "Send /start to @userinfobot on Telegram to get your numeric user ID.",
37
37
userIdLabel: "Telegram User ID (for DM access)",
38
38
allowIdsMode: "dm",
39
+
requireMentionEnvKey: "TELEGRAM_REQUIRE_MENTION",
40
+
requireMentionHelp:
41
+
"Controls Telegram group-chat behavior only — reply only when @mentioned vs. to all group messages. Direct messages are unaffected by this setting and remain subject to pairing and TELEGRAM_ALLOWED_IDS.",
0 commit comments