2.1.19 • Published 6 years ago

vk-fast-longpoll v2.1.19

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

vk-fast-longpoll

RU | Мощный инструмент для работы с VK API, который работает в 25 раз быстрее обычных вызовов API методов.

EN | Powerfull tool for VK api that works 25 times faster then usual api calls

NPM version NPM downloads

Русский

Установка и начало работы

Установка

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 --save

Initializing

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 development
2.1.19

6 years ago

2.1.18

7 years ago

2.1.17

7 years ago

2.1.16

7 years ago

2.1.15

7 years ago

2.1.14

7 years ago

2.1.13

7 years ago

2.1.12

7 years ago

2.1.11

7 years ago

2.1.10

7 years ago

2.1.9

7 years ago

2.1.8

7 years ago

2.1.7

7 years ago

2.1.6

7 years ago

2.1.5

7 years ago

2.1.4

7 years ago

2.1.3

7 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.33

7 years ago

2.0.32

7 years ago

2.0.31

7 years ago

2.0.30

7 years ago

2.0.29

7 years ago

2.0.28

7 years ago

2.0.27

7 years ago

2.0.26

7 years ago

2.0.25

7 years ago

2.0.24

7 years ago

2.0.23

7 years ago

2.0.22

7 years ago

2.0.21

7 years ago

2.0.20

7 years ago

2.0.19

7 years ago

2.0.18

7 years ago

2.0.17

7 years ago

2.0.16

7 years ago

2.0.15

7 years ago

2.0.14

7 years ago

2.0.13

7 years ago

2.0.12

7 years ago

2.0.11

7 years ago

2.0.10

7 years ago

2.0.9

7 years ago

2.0.8

7 years ago

2.0.7

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago