create callback_handler
This commit is contained in:
parent
a58fca01f9
commit
2bac30e711
32
src/main.rs
32
src/main.rs
@ -11,7 +11,7 @@ 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;
|
||||||
use teloxide::dispatching::dialogue::{InMemStorage, PostgresStorage};
|
use teloxide::dispatching::dialogue::{GetChatId, InMemStorage, PostgresStorage};
|
||||||
use teloxide::types::{InlineKeyboardButton, InlineKeyboardMarkup, ReplyMarkup};
|
use teloxide::types::{InlineKeyboardButton, InlineKeyboardMarkup, ReplyMarkup};
|
||||||
use teloxide::{
|
use teloxide::{
|
||||||
payloads::SendMessageSetters,
|
payloads::SendMessageSetters,
|
||||||
@ -90,6 +90,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.inspect(|u: Update| {
|
.inspect(|u: Update| {
|
||||||
eprintln!("{u:#?}"); // Print the update to the console with inspect
|
eprintln!("{u:#?}"); // Print the update to the console with inspect
|
||||||
})
|
})
|
||||||
|
.branch(Update::filter_callback_query().endpoint(callback_handler))
|
||||||
.branch(command_handler(config))
|
.branch(command_handler(config))
|
||||||
.branch(
|
.branch(
|
||||||
Update::filter_message()
|
Update::filter_message()
|
||||||
@ -117,6 +118,35 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn callback_handler(
|
||||||
|
bot: Bot,
|
||||||
|
mut db: DB,
|
||||||
|
q: CallbackQuery,
|
||||||
|
) -> Result<(), teloxide::RequestError> {
|
||||||
|
bot.answer_callback_query(&q.id).await?;
|
||||||
|
|
||||||
|
if let Some(ref data) = q.data {
|
||||||
|
match data.as_str() {
|
||||||
|
"more_info" => {
|
||||||
|
answer_message(
|
||||||
|
&bot,
|
||||||
|
q.chat_id()
|
||||||
|
.clone()
|
||||||
|
.map(|i| i.0)
|
||||||
|
.unwrap_or(q.from.id.0 as i64),
|
||||||
|
&mut db,
|
||||||
|
"more_info",
|
||||||
|
None as Option<InlineKeyboardMarkup>,
|
||||||
|
)
|
||||||
|
.await?
|
||||||
|
}
|
||||||
|
_ => {} // do nothing, yet
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
async fn edit_msg_cmd_handler(
|
async fn edit_msg_cmd_handler(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
mut db: DB,
|
mut db: DB,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user