summaryrefslogtreecommitdiff
path: root/src/commands.rs
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2021-08-04 17:22:21 +0200
committerSanto Cariotti <santo@dcariotti.me>2021-08-04 17:22:21 +0200
commit909e2cbdf8cbb311f4abef2c0c1d176987580a76 (patch)
treedbcfa17a56a12c7549c9867842cd44b14c917de1 /src/commands.rs
parent1be956d27668dcf2052ea82b191ae1917e6cb11b (diff)
feat: get faculties for the /room command
Diffstat (limited to 'src/commands.rs')
-rw-r--r--src/commands.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/commands.rs b/src/commands.rs
index a3a3694..2653600 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -1,3 +1,4 @@
+use crate::browser;
use crate::config::Config;
use std::error::Error;
use teloxide::payloads::SendMessageSetters;
@@ -39,9 +40,27 @@ pub async fn handler(
cx.answer(Command::descriptions()).await?;
}
Command::Room => {
- let url_button =
- InlineKeyboardButton::callback("hello".to_string(), "hello_call".to_string());
- let keyboard = InlineKeyboardMarkup::default().append_row(vec![url_button]);
+ let faculties;
+ let mut faculties_array: Vec<Vec<InlineKeyboardButton>> = vec![];
+ unsafe {
+ faculties = browser::get_faculties().await.unwrap();
+ }
+
+ if let Some(faculties_texts) = faculties {
+ for (key, value) in faculties_texts {
+ faculties_array.push(vec![InlineKeyboardButton::callback(
+ value,
+ format!("faculty_{}", key),
+ )]);
+ }
+ } else {
+ faculties_array.push(vec![InlineKeyboardButton::callback(
+ "No such element".to_string(),
+ "".into(),
+ )]);
+ }
+
+ let keyboard = InlineKeyboardMarkup::new(faculties_array);
cx.answer("Where?").reply_markup(keyboard).await?;
}
}