mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 07:25:36 +01:00
Refactor
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
pub mod callback_data;
|
||||
pub mod utils;
|
||||
|
||||
use core::fmt::Debug;
|
||||
use smartstring::alias::String as SmartString;
|
||||
@@ -23,27 +24,11 @@ use crate::bots::{
|
||||
BotHandlerInternal,
|
||||
};
|
||||
|
||||
use self::callback_data::SearchCallbackData;
|
||||
use self::{callback_data::SearchCallbackData, utils::get_query};
|
||||
|
||||
use super::utils::generic_get_pagination_keyboard;
|
||||
|
||||
|
||||
fn get_query(cq: CallbackQuery) -> Option<String> {
|
||||
cq.message
|
||||
.map(|message| {
|
||||
message
|
||||
.reply_to_message()
|
||||
.map(|reply_to_message| {
|
||||
reply_to_message
|
||||
.text()
|
||||
.map(|text| text.replace(['/', '&', '?'], ""))
|
||||
})
|
||||
.unwrap_or(None)
|
||||
})
|
||||
.unwrap_or(None)
|
||||
}
|
||||
|
||||
|
||||
async fn generic_search_pagination_handler<T, P, Fut>(
|
||||
cq: CallbackQuery,
|
||||
bot: CacheMe<Throttle<Bot>>,
|
||||
|
||||
17
src/bots/approved_bot/modules/search/utils.rs
Normal file
17
src/bots/approved_bot/modules/search/utils.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use teloxide::types::CallbackQuery;
|
||||
|
||||
|
||||
pub fn get_query(cq: CallbackQuery) -> Option<String> {
|
||||
cq.message
|
||||
.map(|message| {
|
||||
message
|
||||
.reply_to_message()
|
||||
.map(|reply_to_message| {
|
||||
reply_to_message
|
||||
.text()
|
||||
.map(|text| text.replace(['/', '&', '?'], ""))
|
||||
})
|
||||
.unwrap_or(None)
|
||||
})
|
||||
.unwrap_or(None)
|
||||
}
|
||||
Reference in New Issue
Block a user