vk-fast-longpoll v2.1.19
vk-fast-longpoll
RU | Мощный инструмент для работы с VK API, который работает в 25 раз быстрее обычных вызовов API методов.
EN | Powerfull tool for VK api that works 25 times faster then usual api calls
Русский
Установка и начало работы
Установка
npm install vk-fast-longpoll --saveИнициализация
const VK = require('vk-fast-longpoll');
const group = new VK('token here');Запуск longpoll соединения
group.longpoll.start();Начинаем слушать сообщения
group.longpoll.on('message', (message) => {
if(!message.isOutbox)
{
//Отвечаем на сообщение
}
});Вызов API методов
Все методы VK должны вызываться с префиксом api например
group.api.messages.send({user_id: 1, message: 'Привет, Паша'});Методы возвращают Promise-ы, поэтому стоит добавлять обработчик ошибок к каждому вызову.
group.api.messages.send({user_id: 1, message: 'Привет, Паша'}).catch(console.error);Все названия методов, а также названия полей полностью соответсвуют названиям из документации VK
Echo пример
const VK = require('vk-fast-longpoll');
const group = new VK('token here');
group.longpoll.start();
group.longpoll.on('message', (message) => {
if(!message.isOutbox)
{
group.api.messages.send({user_id: message.sender, message: message.text}).then(() => {
console.log(message.text);
}).catch(console.error);
}
});Загрузка файлов
//В разработкеEnglish
Installing and getting started
Installing
npm install vk-fast-longpoll --saveInitializing
const VK = require('vk-fast-longpoll');
const group = new VK('token here');Longpoll connection start
group.longpoll.start();Listen to messages
group.longpoll.on('message', (message) => {
if(!message.isOutbox)
{
//Reply message
}
});API method calls
All VK Api methods must be called with api prefix
group.api.messages.send({user_id: 1, message: 'Hello, Pasha'});All methods return Promises, therefor you need to catch errors in every api call.
group.api.messages.send({user_id: 1, message: 'Hello, Pasha'}).catch(console.error);All methods names and fields names are equal as VK Api docs
Echo example
const VK = require('vk-fast-longpoll');
const group = new VK('token here');
group.longpoll.start();
group.longpoll.on('message', (message) => {
if(!message.isOutbox)
{
group.api.messages.send({user_id: message.sender, message: message.text}).then(() => {
console.log(message.text);
}).catch(console.error);
}
});File uploading
//In development8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago