Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
node-vk-bot-api
Advanced tools
Clean API for VK bots based on long poll with multi-dispatch send messages (~75 per second).
Clean API for VK bots based on long poll with multi-dispatch send messages (~75 per second).
$ npm install node-vk-bot-api
Full example you can check in examples
folder.
const app = require('node-vk-bot-api');
// Set token
app.setToken('88935996c67c2qwed1547b79a0c8b0093227e61sd15ce14c62e490aa96c8f8ed3090c9cbcdda92c8fadf1f5c74c');
// Send 'Hello' to user on command '/start'
app.addCommand('/start', (data) => {
const uid = data.user_id;
app.sendMessage({ user_id: uid, message: 'Hello, this is /start command!' }); // => '{ response: [ 1 ] }'
});
// Reply same message if user sent not command.
app.notCommand(data => {
const uid = data.user_id;
const date = data.date;
const msg = data.msg;
app.sendMessage({ user_id: uid, message: msg }); // => '{ response: [ 3 ] }'
});
// Start long poll
app.startLongPoll();
Set token to bot. Function takes one argument: token
(string).
app.setToken('88935996c67c290f47b79a0c8b0093227e916ce14c62e490aa96c8f8ed3090c9cbcdda92c8fadf1f5c74c');
Add command to bot. Function takes two arguments: command
(string) and callback
(function).
app.addCommand('/start', (data) => {
// Make your magic here...
});
Set reply if user sent not command. Function takes one argument: callback
(function).
app.notCommand(data => {
const uid = data.user_id;
app.sendMessage({ user_id: uid, message: 'Sorry, you sent not command to bot.' });
});
Send message (multi-dispatch) to users. Function takes one argument: opts
(object).
app.sendMessage({ user_id: uid, message: 'Hello, world!' });
Get last message from forward message. Function takes one argument: update
(object).
app.getLastMessage({
"response": {
"count": 1,
"items": [{
"id": 480,
"date": 1491653021,
"out": 0,
"user_id": 145003487,
"read_state": 1,
"title": " ... ",
"body": "",
"fwd_messages": [{
"user_id": -138165805,
"date": 1491652976,
"body": "Hello, world!"
}]
}]
}
});
Get message info from forward message. If function detects fwd_messages
, then will call .getLastMessage(update)
. Function takes one argument: update
(object).
app.getForwardMessage({
"response": {
"count": 1,
"items": [{
"id": 480,
"date": 1491653021,
"out": 0,
"user_id": 145003487,
"read_state": 1,
"title": " ... ",
"body": "",
"fwd_messages": [{
"user_id": -138165805,
"date": 1491652976,
"body": "Hello, world!"
}]
}]
}
});
Get long poll params. Function doesn't take arguments.
app.startLongPoll();
Start long poll. Function takes one argument: longPollParams
(object).
System function. Not used by user in bot.
MIT.
FAQs
🤖 VK bot framework for Node.js, based on Bots Long Poll API and Callback API
The npm package node-vk-bot-api receives a total of 178 weekly downloads. As such, node-vk-bot-api popularity was classified as not popular.
We found that node-vk-bot-api 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
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.