diff options
author | Santo Cariotti <santo@dcariotti.me> | 2021-07-28 17:06:56 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2021-07-28 17:06:56 +0200 |
commit | d19420bb8a07a5ff692b2fca126ba43093b36502 (patch) | |
tree | 9c88955764cf44b0fce75df6e4c32670288bde0d /src/main.rs |
init
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 33 |
1 files changed, 33 insertions, 0 deletions
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<AutoSend<Bot>, Message>, + command: Command, +) -> Result<(), Box<dyn Error + Send + Sync>> { + match command { + Command::Help => cx.answer(Command::descriptions()).await?, + }; + + Ok(()) +} + +#[tokio::main] +async fn main() -> Result<(), Box<dyn Error>> { + teloxide::enable_logging!(); + log::info!("Starting bot..."); + + let bot = Bot::from_env().auto_send(); + + teloxide::commands_repl(bot, "unict-reservation", handler).await; + + Ok(()) +} |