use super::core::{BoxFilter, make};
use crate::update::IncomingMessage;
pub fn all() -> BoxFilter {
make(|_| true)
}
pub fn none() -> BoxFilter {
make(|_| false)
}
pub fn private() -> BoxFilter {
make(|m| m.is_private())
}
pub fn group() -> BoxFilter {
make(|m| m.is_group())
}
pub fn channel() -> BoxFilter {
make(|m| m.is_channel())
}
pub fn text() -> BoxFilter {
make(|m| m.text().is_some())
}
pub fn media() -> BoxFilter {
make(|m| m.has_media())
}
pub fn photo() -> BoxFilter {
make(|m| m.has_photo())
}
pub fn document() -> BoxFilter {
make(|m| m.has_document())
}
pub fn forwarded() -> BoxFilter {
make(|m| m.is_forwarded())
}
pub fn reply() -> BoxFilter {
make(|m| m.is_reply())
}
pub fn album() -> BoxFilter {
make(|m| m.album_id().is_some())
}
pub fn any_command() -> BoxFilter {
make(|m| m.is_bot_command())
}
pub fn command(name: impl Into<String>) -> BoxFilter {
let name = name.into();
make(move |m| m.is_command_named(&name))
}
pub fn text_contains(needle: impl Into<String>) -> BoxFilter {
let needle = needle.into();
make(move |m| m.text().is_some_and(|t| t.contains(needle.as_str())))
}
pub fn text_starts_with(prefix: impl Into<String>) -> BoxFilter {
let prefix = prefix.into();
make(move |m| m.text().is_some_and(|t| t.starts_with(prefix.as_str())))
}
pub fn from_user(id: i64) -> BoxFilter {
make(move |m| m.sender_user_id() == Some(id))
}
pub fn in_chat(id: i64) -> BoxFilter {
make(move |m| m.chat_id() == id)
}
pub fn custom<F>(f: F) -> BoxFilter
where
F: Fn(&IncomingMessage) -> bool + Send + Sync + 'static,
{
make(f)
}