From 909e2cbdf8cbb311f4abef2c0c1d176987580a76 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 4 Aug 2021 17:22:21 +0200 Subject: feat: get faculties for the /room command --- src/commands.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/commands.rs') 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![]; + 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?; } } -- cgit v1.2.3-18-g5258