[−][src]Struct matrix_bot_api::handlers::stateless_handler::StatelessHandler
Convenience-handler that can quickly register and call functions without any state (each function-call will result in the same output)
Methods
impl StatelessHandler
[src]
pub fn new() -> StatelessHandler
[src]
pub fn set_cmd_prefix(&mut self, prefix: &str)
[src]
With what prefix commands to the bot will start Default: "!"
pub fn register_handle(
&mut self,
command: &str,
handler: fn(bot: &ActiveBot, message: &Message, tail: &str) -> HandleResult
)
[src]
&mut self,
command: &str,
handler: fn(bot: &ActiveBot, message: &Message, tail: &str) -> HandleResult
)
Register handles
- command: For which command (excluding the prefix!) the handler should be called
- handler: The handler to be called if the given command was received in the room
Handler-function:
- bot: This bot
- message: The message from fractal, containing the room the command was sent in, message body, etc.
- tail: The message-body without prefix and command (e.g. "!roll 12" -> "12")
Example
handler.set_cmd_prefix("BOT:") handler.register_handle("sayhi", foo); foo() will be called, when BOT:sayhi is received by the bot
Trait Implementations
impl MessageHandler for StatelessHandler
[src]
fn handle_message(&mut self, bot: &ActiveBot, message: &Message) -> HandleResult
[src]
fn init_handler(&mut self, _bot: &ActiveBot)
[src]
Auto Trait Implementations
impl RefUnwindSafe for StatelessHandler
impl Send for StatelessHandler
impl Sync for StatelessHandler
impl Unpin for StatelessHandler
impl UnwindSafe for StatelessHandler
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,