Socket
Socket
Sign inDemoInstall

js-vk

Package Overview
Dependencies
67
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    js-vk

JS-VK - a convenient module for working with VK API


Version published
Weekly downloads
15
increased by400%
Maintainers
1
Install size
1.90 MB
Created
Weekly downloads
 

Readme

Source

js-vk

JS-VK - a convenient module for working with VK API

Installation

npm install js-vk

Usage example

const VK = require("js-vk");
const vk = new VK({ 
token: process.env.TOKEN, 
GroupId: process.env.GROUP, 
autoUpdates: true,
secretToken: true,
logs: true // false if you do not want the to be written to a file
});

(async () => {
const result = await vk.api('users.get', { user_id: 1 });
console.log(result);
})();

vk.on('message_new', async (message) => {
console.log(message);
await message.send('Hello World!');
await message.edit(message.message.conversation_message_id + 1, 'Hello World 2!');
return;
});

Keyboard

The keyboard parameter is assigned to the messages.send method

const params = { user_id: process.env.OWNER,
message: "Test message",
vk.keyboard([[{ 
  label: 'Keyboard #1',
  color: 'blue',
  type: 'text',
  payload: {} },
{ 
  label: 'Keyboard #2',
  color: 'blue',
  type: 'text',
  payload: {} 
  }
  ],
    [
      { 
        label: 'Keyboard #3',
        color: 'blue',
        type: 'text',
        payload: {} },
      { 
        label: 'Keyboard #4',
        color: 'blue',
        type: 'text',
        payload: {} 
       }
     ]
    ], 
  { inlineKeyboard: true 
  })
};
// The color parameter can take 4 values: blue (primary), white (secondary), red (negative), green (positive)
// This keyboard has additional parameters inlineKeyboard and oneTime
(async () => {
const params = {
  message: "JS-VK!",
  peer_id: vk.defaultPeerId + 1 || 2000000001
}
const result = await vk.api('messages.send', params);
console.log(result);
})();

(async () => {
const params = {
  message: "JS-VK!",
  peer_id: vk.defaultPeerId + 1 || 2000000001
}
const result = await vk.api.messages.send(params);
console.log(result);
})();

FAQs

Last updated on 22 Sep 2021

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