pub enum MessageCondition {
Any,
Eq(String),
Contains(String),
NotContains(String),
RoleIs(String),
RoleNot(String),
LenGt(usize),
Custom(Arc<dyn Fn(&ChatMessage) -> bool + Send + Sync>),
Empty,
All(Vec<MessageCondition>),
AnyOf(Vec<MessageCondition>),
Regex(String),
}
Expand description
Conditions for triggering reactive message handlers
Variants§
Any
Always trigger
Eq(String)
Trigger if message content equals exact string
Contains(String)
Trigger if message content contains substring
NotContains(String)
Trigger if message content does not contain substring
RoleIs(String)
Trigger if sender role matches
RoleNot(String)
Trigger if sender role does not match
LenGt(usize)
Trigger if message length is greater than specified
Custom(Arc<dyn Fn(&ChatMessage) -> bool + Send + Sync>)
Custom condition function
Empty
Empty
All(Vec<MessageCondition>)
Trigger if all conditions are met
AnyOf(Vec<MessageCondition>)
Trigger if any condition is met
Regex(String)
Trigger if message content matches regex
Implementations§
Source§impl MessageCondition
impl MessageCondition
Sourcepub fn matches(&self, event: &MessageEvent) -> bool
pub fn matches(&self, event: &MessageEvent) -> bool
Check if the condition is met for the given message event
Trait Implementations§
Source§impl Clone for MessageCondition
impl Clone for MessageCondition
Source§fn clone(&self) -> MessageCondition
fn clone(&self) -> MessageCondition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for MessageCondition
impl !RefUnwindSafe for MessageCondition
impl Send for MessageCondition
impl Sync for MessageCondition
impl Unpin for MessageCondition
impl !UnwindSafe for MessageCondition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more