[][src]Struct vk_bot::core::Core

pub struct Core { /* fields omitted */ }

Core accepts user-defined handlers, and invokes them when needed. Note that only one handler (the first found, according to the Core::on docs) is called for a given message.

Works like a builder.

Methods

impl Core[src]

pub fn new() -> Self[src]

Creates a new Core.

pub fn cmd_prefix(self, cmd_prefix: &str) -> Self[src]

Modifies this Core's command prefix.

pub fn on(self, event: Event, handler: Handler) -> Self[src]

Adds a new event handler to this Core.

See Event for possible events.

Be very careful in implementation of Event::MessageReply. It will be triggered for every message your community admins or the bot sends, including ones sent through an Event::MessageReply or Event::NoMatch handler!

Handler for the Event::MessageNew is built-in, not changeable, and works like this:

# cause action
1 action field on object Event::ServiceAction
2 special {"command": "start"} payload Event::Start
3 exact payload match set up via Core::payload respective handler
4 'dynamic' payload match set up via Core::dyn_payload respective handler
5 command handlers (Core::cmd_prefix and Core::cmd) respective handler
6 regex handlers (Core::regex) respective handler
7 anything except Event::MessageReply and Event::NoMatch Event::NoMatch

pub fn payload(self, payload: &str, handler: Handler) -> Self[src]

Adds a new payload handler to this Core.

See also Core::dyn_payload.

pub fn dyn_payload(self, tester: Tester, handler: Handler) -> Self[src]

Adds a new dynamic (provided a Tester) payload handler to this Core.

See also Core::payload.

pub fn cmd(self, cmd: &str, handler: Handler) -> Self[src]

Adds a new command (exact string after command prefix) handler to this Core.

pub fn regex(self, regex: &str, handler: Handler) -> Self[src]

Adds a new regex handler to this Core.

pub fn handle(&self, req: &CallbackAPIRequest, api: Arc<Mutex<APIClient>>)[src]

Handles a request by telling the appropriate Handler to do so.

Trait Implementations

impl Default for Core[src]

impl Clone for Core[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Core[src]

Auto Trait Implementations

impl Send for Core

impl Sync for Core

Blanket Implementations

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

impl<T, U> TryInto 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> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

fn get_type(&self) -> TypeId

Get the TypeId of this object.

impl<T> IntoCollection for T

impl<T, I> AsResult for T where
    I: Input, 

impl<T> Erased for T