From 9b229737e671fba989191409e927e677a4c960f7 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 18 Aug 2021 07:32:25 +0200 Subject: feat: get timetable of a space --- src/callbacks.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/callbacks.rs') diff --git a/src/callbacks.rs b/src/callbacks.rs index a82d5e9..53ae07c 100644 --- a/src/callbacks.rs +++ b/src/callbacks.rs @@ -49,6 +49,48 @@ pub async fn handler( } } }, + "space" => unsafe { + // Select the sapce + match browser::select_option("select2-results__option", "data-select2-id", call[2]) + .await + { + Ok(result) => { + if result { + let timetable = browser::get_timetable().await.unwrap(); + let keyboard = make_inline_keyboard( + &timetable, + "timetable", + chat_id.parse::().unwrap(), + ) + .await; + + // Edit the previous spaces message with timetable' buttons + cx.requester + .edit_message_text( + chat_id.to_string(), + cx.update.message.clone().unwrap().id, + "When?", + ) + .await?; + + cx.requester + .edit_message_reply_markup( + chat_id.to_string(), + cx.update.message.clone().unwrap().id, + ) + .reply_markup(keyboard) + .await?; + + return Ok(true); + } else { + return Ok(false); + } + } + Err(_) => { + return Ok(false); + } + } + }, _ => Ok(false), } } -- cgit v1.2.3-18-g5258