Index: Cargo.lock ================================================================== --- Cargo.lock +++ Cargo.lock @@ -2025,14 +2025,16 @@ "lazy_static", "regex", "reqwest", "rss", "sedregex", + "serde", "smol", "sqlx", "stacked_errors", "tgbot", + "toml", "url", ] [[package]] name = "rustc-hash" @@ -2857,18 +2859,20 @@ "tokio", ] [[package]] name = "toml" -version = "0.9.10+spec-1.1.0" +version = "0.9.11+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0825052159284a1a8b4d6c0c86cbc801f2da5afd2b225fa548c72f2e74002f48" +checksum = "f3afc9a848309fe1aaffaed6e1546a7a14de1f935dc9d89d32afd9a44bab7c46" dependencies = [ + "indexmap", "serde_core", "serde_spanned", "toml_datetime", "toml_parser", + "toml_writer", "winnow", ] [[package]] name = "toml_datetime" @@ -2886,10 +2890,16 @@ checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44" dependencies = [ "winnow", ] +[[package]] +name = "toml_writer" +version = "1.0.6+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607" + [[package]] name = "tower" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" Index: Cargo.toml ================================================================== --- Cargo.toml +++ Cargo.toml @@ -17,13 +17,15 @@ lazy_static = "1.5.0" regex = "1.10.6" reqwest = { version = "0.13.1", features = [ "brotli", "socks", "deflate" ]} rss = "2.0.9" sedregex = "0.2.5" +serde = "1.0.228" smol = "2.0.2" stacked_errors = "0.7.1" sqlx = { version = "0.8", features = [ "postgres", "runtime-tokio-rustls", "chrono", "macros" ], default-features = false } +toml = "0.9.11+spec-1.1.0" url = "2.5.8" [profile.release] lto = true codegen-units = 1 Index: src/command.rs ================================================================== --- src/command.rs +++ src/command.rs @@ -70,11 +70,11 @@ "/disable" => conn.disable(number, sender).await.stack()?.into(), _ => bail!("Command {command} {words:?} not handled."), }, } } else { - "This command needs exacly one number.".into() + "This command needs exactly one number.".into() }; core.tg.send(reply, Some(msg.chat.get_id()), None).await.stack()?; Ok(()) } Index: src/core.rs ================================================================== --- src/core.rs +++ src/core.rs @@ -356,11 +356,11 @@ impl UpdateHandler for Core { /// Dispatches an incoming Telegram update to a matching command handler and reports handler errors to the originating chat. /// /// This method inspects the update; if it contains a message that can be parsed as a bot command, /// it executes the corresponding command handler. If the handler returns an error, the error text - /// is sent back to the message's chat using MarkdownV2 formatting. Unknown commands produce an erro + /// is sent back to the message's chat using MarkdownV2 formatting. Unknown commands produce an error /// which is also reported to the chat. async fn handle (&self, update: Update) { if let UpdateType::Message(msg) = update.update_type && let Ok(cmd) = Command::try_from(msg) { Index: src/tg_bot.rs ================================================================== --- src/tg_bot.rs +++ src/tg_bot.rs @@ -1,5 +1,9 @@ +use serde::{ + Deserialize, + Serialize, +}; use stacked_errors::{ Result, StackableErr, }; use tgbot::{ @@ -6,15 +10,31 @@ api::Client, types::{ Bot, ChatPeerId, GetBot, + InlineKeyboardButton, + InlineKeyboardMarkup, Message, ParseMode, SendMessage, }, }; + +#[derive(Serialize, Deserialize, Debug)] +enum Callback { + // List all feeds (version, name to show) + List(u8, String), +} + +fn get_kb (cb: &Callback) -> Result { + let mark = InlineKeyboardMarkup::from(vec![vec![ + InlineKeyboardButton::for_callback_data("1", + toml::to_string(&Callback::List(0,"xxx".to_owned())).stack()?), + ]]); + Ok(mark) +} #[derive(Clone)] pub struct Tg { pub me: Bot, pub owner: ChatPeerId,