Sepparated the code out into 3 more library crates: cryptography, entity and pass_manager

This commit is contained in:
2023-06-01 14:42:35 +03:00
parent c40ffafd69
commit cda07b4d84
46 changed files with 360 additions and 268 deletions

View 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
View File

@ -0,0 +1,3 @@
//! This module consists of endpoints to handle callbacks
pub mod delete_message;