summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2021-07-28 17:06:56 +0200
committerSanto Cariotti <santo@dcariotti.me>2021-07-28 17:06:56 +0200
commitd19420bb8a07a5ff692b2fca126ba43093b36502 (patch)
tree9c88955764cf44b0fce75df6e4c32670288bde0d
init
-rw-r--r--.gitignore3
-rw-r--r--Cargo.toml10
-rw-r--r--src/main.rs33
3 files changed, 46 insertions, 0 deletions
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<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(())
+}