❮vk-chat-bot❯
Package for easy creation of chat bots for VK communities (groups). Uses Callback API. documentation » ⋅ changelog » ⋅ features ⋅ usage ⋅ contributing ⋅ license
Features
- Easy to use — setting up behavior is simple — see 2. Behavior setup below
- Respects the quota — the package calls VK API not more then 20 times/second, so you don't exceed the quota
The version of VK API used by this package can be found here.
Usage
Installation
$ yarn add vk-chat-bot
Example
You can find an example bot in the u32i64/vk-chat-bot-example
repository.
-
Deploying on Glitch
Simply press the button below and follow the
SETUP.md
file there: -
Deploying on Heroku
You can find a step-by-step guide on deploying the example to Heroku here.
Quick Start
1. Preparation
First, require()
the package:
const vk = ;
Then, create your bot using the vk.bot
function (see Params object for more information about params
):
const params = vkToken: 'your_vk_access_token' confirmationToken: 'f123456' groupId: 1234567 secret: 's3r10us1y_s3cr3t_phr4s3' port: 12345 cmdPrefix: '/'; var bot core = vk;
2. Behavior setup
See Core
wiki to learn more about behavior functions.
Here are some examples:
// Use stuff from the package...const Color button Keyboard = vkkbd; // ...to create a keyboard like this.// +-----------+---------+----------+----------+// | Secondary | Primary | Negative | Positive |// +-----------+---------+----------+----------+// | Maximum rows is 10, columns - 4. |// +-------------------------------------------+var kbd = /* Row (array of buttons) */ buttontext'Secondary' buttontext'Primary' ColorPrimary buttontext'Negative' ColorNegative buttontext'Positive' ColorPositive buttontext'Maximum rows is 10, columns - 4.' ; // When user presses the `Start` button...// (you have to enable the button in community settings)core;
// Searches for cmd_prefix + 'help', e.g. '/help'core;
// Use case-insensitive regular expression to find words 'hi', 'hello' or 'hey'core;
3. Start it!
Start the bot:
botstart;
The bot will log some useful information, see Logging documentation for more information.
Contributing
- Something does not seem right or you have a feature request? Open an issue.
- You know how to make
vk-chat-bot
better? Open a pull request!
License
This project is licensed under the terms of the MIT license.