From d19420bb8a07a5ff692b2fca126ba43093b36502 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 28 Jul 2021 17:06:56 +0200 Subject: init --- src/main.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main.rs (limited to 'src') diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..abe7f2e --- /dev/null +++ b/src/main.rs @@ -0,0 +1,33 @@ +use std::error::Error; +use teloxide::prelude::*; +use teloxide::utils::command::BotCommand; + +#[derive(BotCommand)] +#[command(rename = "lowercase", description = "These commands are supported:")] +enum Command { + #[command(description = "display this text")] + Help, +} + +async fn handler( + cx: UpdateWithCx, Message>, + command: Command, +) -> Result<(), Box> { + match command { + Command::Help => cx.answer(Command::descriptions()).await?, + }; + + Ok(()) +} + +#[tokio::main] +async fn main() -> Result<(), Box> { + teloxide::enable_logging!(); + log::info!("Starting bot..."); + + let bot = Bot::from_env().auto_send(); + + teloxide::commands_repl(bot, "unict-reservation", handler).await; + + Ok(()) +} -- cgit v1.2.3-18-g5258