From a6d83851f7454e8a27030fc78d64a0feec7d1e4e Mon Sep 17 00:00:00 2001 From: lew Date: Fri, 10 Apr 2026 18:40:00 +0100 Subject: [PATCH] telegram: register parameterless commands in the command list for autocomplete --- src/telegram.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/telegram.rs b/src/telegram.rs index 0d94133..41ca697 100644 --- a/src/telegram.rs +++ b/src/telegram.rs @@ -56,8 +56,17 @@ pub async fn notification_task(bot: Bot, chat_id: ChatId, mut rx: Receiver<(Entr } } -/// Run the Telegram bot that listens for /allow_ and /deny_ commands. +/// Run the Telegram bot that listens for commands. pub async fn bot_task(bot: Bot, chat_id: ChatId, data_dir: PathBuf) { + let commands = vec![ + teloxide::types::BotCommand::new("pending", "List pending entries"), + teloxide::types::BotCommand::new("approved", "List approved entries"), + teloxide::types::BotCommand::new("denied", "List denied entries"), + ]; + if let Err(e) = bot.set_my_commands(commands).await { + tracing::error!("failed to set bot commands: {e}"); + } + let handler = Update::filter_message().endpoint( |bot: Bot, msg: Message, data_dir: PathBuf, chat_id: ChatId| async move { let text = msg.text().unwrap_or(""); @@ -102,9 +111,9 @@ pub async fn bot_task(bot: Bot, chat_id: ChatId, data_dir: PathBuf) { Ok(entry) => { let short_id = entry.short_id(); let text = format!( - "Entry ({:?}):\n\nName: {}\nWebsite: {}\nDate: {}\n\n{}\n\n/allow_{}\n/deny_{}\n/delete_{}", + "Entry ({:?}):\n\nName: {}\nWebsite: {}\nDate: {}\n\n{}\n\n/allow_{}\n/deny_{}", entry.meta.status, entry.meta.name, entry.meta.website, - entry.meta.date, entry.body, short_id, short_id, short_id + entry.meta.date, entry.body, short_id, short_id ); bot.send_message(msg.chat.id, &text).await?;