diff options
author | Santo Cariotti <santo@dcariotti.me> | 2021-08-18 07:32:25 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2021-08-18 07:32:25 +0200 |
commit | 9b229737e671fba989191409e927e677a4c960f7 (patch) | |
tree | 90a0b9aa4b1dcefcd0ca81086d7dcb4f8e2925e0 /src/callbacks.rs | |
parent | 655e487deb427c5b46e47aab50b761be78a1eb90 (diff) |
feat: get timetable of a space
Diffstat (limited to 'src/callbacks.rs')
-rw-r--r-- | src/callbacks.rs | 42 |
1 files changed, 42 insertions, 0 deletions
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::<i64>().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), } } |