Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
vk-chat-bot
Advanced tools
Changelog
[15.0.0] - 2019-06-15
.d.ts
TypeScript declaration files.kbd.Button
-> kbd.button
.kbd.colors.<somecolor>
-> kbd.Color.<Somecolor>
.jsdoc
+ minami
theme -> typedoc
.log.types.<sometype>
-> log.MessageType.<Sometype>
(see log
docs).replyText
nor attachment
was supplied, this line might have caused a very informative log message to appear, namely
ctx warn ctx
because there were more arguments supplied than needed. Thanks TypeScript!bot
and some other functions are not provided aka rudimentary input validation.
log.requireParam
.log.requireFunction
.rollup
devDependency (and its plugins).Readme
Package for easy creation of chat bots for VK communities (groups). Uses Callback API.
documentation » ⋅ changelog » ⋅ features ⋅ usage ⋅ contributing ⋅ license
$ npm i vk-chat-bot
You can find an example bot in the u32i64/vk-chat-bot-example
repository.
Also, a step-by-step Heroku Deploy Guide can guide you through the process of deploying u32i64/vk-chat-bot-example
to Heroku.
First, require()
the package:
const vk = require('vk-chat-bot');
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.bot(params);
See Core
wiki to learn more about behavior functions.
Here are some examples:
// Use stuff from the package...
const { Color, button, Keyboard } = vk.kbd;
// ...to create a keyboard like this.
// +-----------+---------+----------+----------+
// | Secondary | Primary | Negative | Positive |
// +-----------+---------+----------+----------+
// | Maximum rows is 10, columns - 4. |
// +-------------------------------------------+
var kbd = new Keyboard([
[ /* Row (array of buttons) */
button.text('Secondary'),
button.text('Primary', Color.Primary),
button.text('Negative', Color.Negative),
button.text('Positive', Color.Positive)
],
[
button.text('Maximum rows is 10, columns - 4.')
],
]);
// When user presses the `Start` button...
// (you have to enable the button in community settings)
core.on('start', $ => {
// ...send them our keyboard.
$.text("Thanks for messaging us! Choose from the options below:");
$.keyboard(kbd);
// Here, $.send() is added automatically.
});
// Searches for cmd_prefix + 'help', e.g. "/help"
core.cmd('help', $ => {
// core.help() returns the help message
$.text('Test Bot v1.0' + core.help());
// Attach an image from
// https://vk.com/team?z=photo6492_45624077
$.attach('photo', 6492, 456240778);
}, 'shows the help message');
// Use case-insensitive regular expression to find words "hi", "hello" or "hey"
core.regex(/h(i|ello|ey)/i, $ => {
$.text('Hello, I am a test bot. You said: ' + $.msg);
});
Start the bot:
bot.start();
The bot will log some useful information, see Logging documentation for more information.
vk-chat-bot
better? Open a pull request!This project is licensed under the terms of the MIT license.
FAQs
Package for easy creation of chat bots for VK communities (uses Callback API).
We found that vk-chat-bot demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).