Sepparated the code out into 3 more library crates: cryptography, entity and pass_manager
This commit is contained in:
27
src/callbacks/delete_message.rs
Normal file
27
src/callbacks/delete_message.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use crate::markups::deletion_markup;
|
||||
use teloxide::{adaptors::Throttle, dispatching::DpHandlerDescription, prelude::*};
|
||||
|
||||
/// Deletes the message from the callback
|
||||
async fn run(bot: Throttle<Bot>, q: CallbackQuery) -> crate::Result<()> {
|
||||
if let Some(msg) = q.message {
|
||||
if let Err(err) = bot.delete_message(msg.chat.id, msg.id).await {
|
||||
let _ = bot
|
||||
.send_message(msg.chat.id, "Error deleting the message")
|
||||
.reply_markup(deletion_markup())
|
||||
.await;
|
||||
return Err(err.into());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Filters the delete_message callbacks
|
||||
fn filter(q: CallbackQuery) -> bool {
|
||||
matches!(q.data.as_deref(), Some("delete_message"))
|
||||
}
|
||||
|
||||
/// Gets a handler for deleting the message
|
||||
#[inline]
|
||||
pub fn get_handler() -> Handler<'static, DependencyMap, crate::Result<()>, DpHandlerDescription> {
|
||||
dptree::filter(filter).endpoint(run)
|
||||
}
|
3
src/callbacks/mod.rs
Normal file
3
src/callbacks/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
//! This module consists of endpoints to handle callbacks
|
||||
|
||||
pub mod delete_message;
|
Reference in New Issue
Block a user