[−][src]Struct vk_bot::core::Core
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(&self) -> 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
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom 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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto 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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Typeable for T where
T: Any,
T: Any,
impl<T> IntoCollection for T
fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
A: Array<Item = T>,
fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
A: Array<Item = U>,
F: FnMut(T) -> U,
A: Array<Item = U>,
F: FnMut(T) -> U,
impl<T, I> AsResult for T where
I: Input,
I: Input,