[][src]Struct matrix_bot_api::handlers::stateless_handler::StatelessHandler

pub struct StatelessHandler { /* fields omitted */ }

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]

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]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err