display event buttons
This commit is contained in:
parent
e9a44a221d
commit
98be2b0f7d
17
src/main.rs
17
src/main.rs
@ -6,6 +6,8 @@ use crate::admin::{secret_command_handler, SecretCommands};
|
|||||||
use crate::db::DB;
|
use crate::db::DB;
|
||||||
|
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
use chrono_tz::Asia;
|
||||||
|
use db::schema::events;
|
||||||
use envconfig::Envconfig;
|
use envconfig::Envconfig;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use teloxide::dispatching::dialogue::serializer::Json;
|
use teloxide::dispatching::dialogue::serializer::Json;
|
||||||
@ -231,7 +233,7 @@ async fn user_command_handler(
|
|||||||
.unwrap_or("Please, set content of this message".into());
|
.unwrap_or("Please, set content of this message".into());
|
||||||
let msg = bot
|
let msg = bot
|
||||||
.send_message(msg.chat.id, text)
|
.send_message(msg.chat.id, text)
|
||||||
.reply_markup(make_start_buttons())
|
.reply_markup(make_start_buttons(&mut db).await)
|
||||||
.parse_mode(teloxide::types::ParseMode::Html)
|
.parse_mode(teloxide::types::ParseMode::Html)
|
||||||
.await?;
|
.await?;
|
||||||
db.set_message_literal(msg.chat.id.0, msg.id.0, literal)
|
db.set_message_literal(msg.chat.id.0, msg.id.0, literal)
|
||||||
@ -247,13 +249,12 @@ async fn user_command_handler(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_start_buttons() -> InlineKeyboardMarkup {
|
async fn make_start_buttons(db: &mut DB) -> InlineKeyboardMarkup {
|
||||||
let mut buttons = vec![
|
let mut buttons: Vec<Vec<InlineKeyboardButton>> = db.get_all_events().await.iter()
|
||||||
vec![
|
.map(|e| vec![InlineKeyboardButton::callback(
|
||||||
InlineKeyboardButton::callback("Button 1", "callback_data_1"),
|
e.time.with_timezone(&Asia::Dubai).to_string(),
|
||||||
InlineKeyboardButton::callback("Button 2", "callback_data_2"),
|
format!("event:{}", e.id)
|
||||||
],
|
)]).collect();
|
||||||
];
|
|
||||||
buttons.push(vec![InlineKeyboardButton::callback("More info", "more_info")]);
|
buttons.push(vec![InlineKeyboardButton::callback("More info", "more_info")]);
|
||||||
|
|
||||||
InlineKeyboardMarkup::new(buttons)
|
InlineKeyboardMarkup::new(buttons)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user