Socket
Socket
Sign inDemoInstall

node-ponyapi

Package Overview
Dependencies
59
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-ponyapi

Simple Node.js VK API realization


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Node PonyApi - Simple Node.js VK API Realization

Travis GitHub release

Installation

npm i node-ponyapi

Usage

var PonyApi = require('node-ponyapi')
var bot = new PonyApi('Your Access Token')

// Method that returns current user ID, first name and last name
bot.users.get((res) => {
    console.log(res);
})

// Emits a "message" event when some message received.
bot.on('message', (msg) => {
        console.log(msg);
})

Table of contents


API methods

You can use any available method from VK API. For example, this method returns users with IDs 1, 2, 3:

bot.users.get({user_ids: '1,2,3'}, (res) => {
    console.log(res);
})

Look for another available methods here - https://vk.com/dev/methods

LongPool events

'message'

Message received.

bot.on('message', (msg) => {
        console.log(`Received message with text: '${msg.text}'`);
})

'chat_invite_user'

User entered chat.

bot.on('chat_invite_user', (msg) => {
        console.log(`User ${msg.attachments.source_mid} added to chat room`);
})

'chat_kick_user'

User leave chat.

bot.on('chat_kick_user', (msg) => {
        console.log(`User ${msg.attachments.source_mid} leave a chat`);
})

'chat_title_update'

Chat name changed

bot.on('chat_title_update', (msg) => {
        console.log(`Chat name is changed to "${msg.attachments.source_text}"`);
})

'chat_photo_update'

Chat photo changed

bot.on('chat_photo_update', (msg) => {
        console.log('Chat photo is changed');
})

'chat_create'

Chat created

bot.on('chat_create', (msg) => {
        console.log('Chat is changed');
})

Messaging

Object "msg" has two methods for send messages.

Reply method sends message with attaching original message:

bot.on('message', (msg) => {
    if (msg.text == 'test') 
        msg.reply('passed')
})

Send method just send message to peer of original message:

bot.on('message', (msg) => {
    if (msg.text == 'test') 
        msg.send('passed')
})

FAQs

Last updated on 23 Nov 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc