Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vk-fast-longpoll

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vk-fast-longpoll

VK Lib for better performance

  • 2.1.18
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by33.33%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 03 Aug 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc