feat(channel): add mention_only option for Telegram groups
Adds mention_only config option to Telegram channel, allowing the bot to only respond to messages that @-mention the bot in group chats. Direct messages are always processed regardless of this setting. Behavior: - When mention_only = true: Bot only responds to group messages containing @botname - When mention_only = false (default): Bot responds to all allowed messages - DM/private chats always work regardless of mention_only setting Implementation: - Fetch and cache bot username from Telegram API on startup - Check for @botname mention in group messages - Strip mention from message content before processing Config example: [channels.telegram] bot_token = "your_token" mention_only = true Changes: - src/config/schema.rs: Add mention_only to TelegramConfig - src/channels/telegram.rs: Implement mention_only logic + 6 new tests - src/channels/mod.rs: Update factory calls - src/cron/scheduler.rs: Update constructor call - src/onboard/wizard.rs: Update wizard config - src/daemon/mod.rs: Update test config - src/integrations/registry.rs: Update test config - TESTING_TELEGRAM.md: Add mention_only test section - CHANGELOG.md: Document feature Risk: medium Backward compatible: Yes (default: false)
This commit is contained in:
parent
3b75c6cc42
commit
c0a80ad656
10 changed files with 264 additions and 54 deletions
|
|
@ -942,8 +942,12 @@ pub async fn doctor_channels(config: Config) -> Result<()> {
|
|||
channels.push((
|
||||
"Telegram",
|
||||
Arc::new(
|
||||
TelegramChannel::new(tg.bot_token.clone(), tg.allowed_users.clone())
|
||||
.with_streaming(tg.stream_mode, tg.draft_update_interval_ms),
|
||||
TelegramChannel::new(
|
||||
tg.bot_token.clone(),
|
||||
tg.allowed_users.clone(),
|
||||
tg.mention_only,
|
||||
)
|
||||
.with_streaming(tg.stream_mode, tg.draft_update_interval_ms),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
|
@ -1262,8 +1266,12 @@ pub async fn start_channels(config: Config) -> Result<()> {
|
|||
|
||||
if let Some(ref tg) = config.channels_config.telegram {
|
||||
channels.push(Arc::new(
|
||||
TelegramChannel::new(tg.bot_token.clone(), tg.allowed_users.clone())
|
||||
.with_streaming(tg.stream_mode, tg.draft_update_interval_ms),
|
||||
TelegramChannel::new(
|
||||
tg.bot_token.clone(),
|
||||
tg.allowed_users.clone(),
|
||||
tg.mention_only,
|
||||
)
|
||||
.with_streaming(tg.stream_mode, tg.draft_update_interval_ms),
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue