Command prefix.
Command handlers.
Dynamic payload handlers. (those which use functions to determine whether a handler is suitable)
Command prefix, escaped for usage in regular expressions
Are event warnings enabled?
Exact payload handlers.
Group ID.
The help message.
Is this Core
locked?
Regular expression handlers.
Registers a command handler.
Handler is called if the message begins with cmd_prefix
(defined in the parameters) + command
command
function which will handle the message
the description of what this command does, to be used in help messages.
Handles an event.
Generates the help message.
Returns handler counts, except message_new
event since it is built-in.
Returns the help message.
Indicates whether this Core
is locked, and prints a message
to notify the user if it is locked.
Locks this Core
, so new handlers can't be added,
and generates the help message for later usage.
Disables warnings about missing event handlers.
Registers an event handler.
Does not work for message_new
, as its handler is defined by vk-chat-bot
itself.
Event | Description |
---|---|
message_allow |
User allowed sending messages to him/her |
message_deny |
User disallowed sending messages to him/her |
message_reply |
New message sent by community administrator (or by the bot itself) |
message_edit |
Message edited by user |
message_typing_state |
User is typing a message |
Event type | When handler is called |
---|---|
start |
If the message's payload is {"command": "start"} (i.e. Start button pressed) |
service_action |
Service action message received |
no_match |
When no matching cmd() or regex() handler is found |
handler_error |
If an error is thrown in a handler |
service_action
eventThe
$.obj.action
object contains information about the service action. It contains the following fields:
type (string) — action type, one of:
`chat_photo_update` — chat photo updated
`chat_photo_remove` — chat photo removed
`chat_create` — chat created
`chat_title_update` — chat title updated
`chat_invite_user` — user was invited to chat
`chat_kick_user` — user was kicked from the chat
`chat_pin_message` — a message was pinned
`chat_unpin_message` — a message was unpinned
`chat_invite_user_by_link` — user joined the chat by link
member_id (integer):
user id (if > 0), which was invited or kicked (if < 0, see `email` field)
(`chat_invite_user`, `chat_invite_user_by_link`, `chat_kick_user`)
user id, which pinned or unpinned a message
(`chat_pin_message`, `chat_unpin_message`)
text (string):
chat name
(`chat_create`, `chat_title_update`)
email (string):
email, which was invited or kicked
(`chat_invite_user`, `chat_kick_user`, member_id < 0)
photo (object) — chat picture, contains:
photo_50 (string): URL of image 50 x 50 px
photo_100 (string): URL of image 100 x 100 px
photo_200 (string): URL of image 200 x 200 px
Parses the request, creates a Context, and proceeds to call Core.event to handle the event
body of the request, in parsed JSON
Registers a payload handler.
Note: exact handlers are searched first, and only if they don't match, the search for a dynamic handler begins.
exact payload to handle, or a function (type Tester) which will determine whether to handle the payload or not.
function which will handle the message
Registers a regex handler.
function which will handle the message
Registers a handler for message_new
event.
Tries to handle the message in the given Context
with a command handler.
was the message handled?
Tries to handle the message in the given Context
with a payload handler.
was the message handled?
Tries to handle the message in the given Context
with a regex handler.
was the message handled?
Handlers for events.
Generated using TypeDoc
Dispatches message handling to appropriate handlers, and is used for setting these handlers.
Handlers for the
message_new
event will be searched in this order:service_action
eventStart
button => on handler for thestart
eventFor other events, a matching on handler will be called.