From d19420bb8a07a5ff692b2fca126ba43093b36502 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 28 Jul 2021 17:06:56 +0200 Subject: init --- .gitignore | 3 +++ Cargo.toml | 10 ++++++++++ src/main.rs | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f4b73a1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/target +Cargo.lock +.envrc diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..06ee770 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "unict-reservation" +version = "0.1.0" +edition = "2018" + +[dependencies] +teloxide = { version = "0.4", features = ["auto-send", "macros"] } +log = "0.4.8" +pretty_env_logger = "0.4.0" +tokio = { version = "1.3", features = ["rt-multi-thread", "macros"] } 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