Update channel handler

This commit is contained in:
2022-12-16 23:12:24 +01:00
parent 95eb3e0862
commit 0117a6b567
2 changed files with 6 additions and 15 deletions

View File

@@ -84,7 +84,7 @@ pub async fn download_file(
let headers = response.headers(); let headers = response.headers();
log::debug!("Download headers: {:?}", headers); log::info!("Download headers: {:?}", headers);
let filename = headers let filename = headers
.get("content-disposition") .get("content-disposition")

View File

@@ -15,14 +15,9 @@ type BotHandler = Handler<
type BotCommands = Option<Vec<teloxide::types::BotCommand>>; type BotCommands = Option<Vec<teloxide::types::BotCommand>>;
fn ignore_channel_messages() -> crate::bots::BotHandler fn ignore_channel_messages() -> crate::bots::BotHandler {
{ Update::filter_channel_post()
Update::filter_message() .endpoint(|_message: Message, _bot: AutoSend<Bot>| async { Ok(()) })
.chain(dptree::filter(move |message: Message| {
message.chat.is_channel()
})).endpoint(|_message: Message, _bot: AutoSend<Bot>| async {
Ok(())
})
} }
fn get_pending_handler() -> BotHandler { fn get_pending_handler() -> BotHandler {
@@ -38,9 +33,7 @@ fn get_pending_handler() -> BotHandler {
dptree::entry() dptree::entry()
.branch(ignore_channel_messages()) .branch(ignore_channel_messages())
.branch( .branch(Update::filter_message().chain(dptree::endpoint(handler)))
Update::filter_message().chain(dptree::endpoint(handler))
)
} }
fn get_blocked_handler() -> BotHandler { fn get_blocked_handler() -> BotHandler {
@@ -53,9 +46,7 @@ fn get_blocked_handler() -> BotHandler {
dptree::entry() dptree::entry()
.branch(ignore_channel_messages()) .branch(ignore_channel_messages())
.branch( .branch(Update::filter_message().chain(dptree::endpoint(handler)))
Update::filter_message().chain(dptree::endpoint(handler))
)
} }
pub fn get_bot_handler(status: crate::bots_manager::BotStatus) -> (BotHandler, BotCommands) { pub fn get_bot_handler(status: crate::bots_manager::BotStatus) -> (BotHandler, BotCommands) {