Socket
Socket
Sign inDemoInstall

node-vk-bot-api

Package Overview
Dependencies
2
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-vk-bot-api


Version published
Maintainers
1
Created

Readme

Source

node-vk-bot-api node-vk-bot-api

node-vk-bot-api

API for VK bots on long poll.

Install

$ npm i node-vk-bot-api

Example

const API = require('node-vk-bot-api')

const bot = new API(process.env.TOKEN)

bot.command('start', ({ reply }) => reply('This is start!'))
bot.hears(/(car|tesla)/, ({ reply }) => reply('I love Tesla!'))
bot.on(({ reply }) => reply('What?'))

bot.listen()

Methods

constructor(options)

ParameterTypeRequried
tokenstringyes

Create bot.

const bot = new API(process.env.TOKEN)

.command(command, callback)

ParameterTypeRequried
commandstringyes
callbackfunctionyes

Add command w/ strict match.

bot.command('start', ({ reply }) => {
  reply('This is start!')
})

.hears(command, callback)

ParameterTypeRequried
commandstringyes
callbackfunctionyes

Add command w/ match like RegEx.

bot.hears(/(car|tesla)/, ({ reply }) => {
  reply('I love Tesla!')
})

.on(callback)

ParameterTypeRequried
callbackfunctionyes

Add reserved callback.

bot.on(({ reply }) => {
  reply('What?')
})

.listen()

Start listen.

Context Methods

.reply(message, attachment)

ParameterTypeRequried
messagestringyes (no, if setten attachment)
attachmentstringyes (no, if setten message)

Send a message to the current user.

.sendMessage(peer, command, callback)

ParameterTypeRequried
peernumberyes
messagestringyes (no, if setten attachment)
attachmentstringyes (no, if setten message)

Send a message to any user.

License

MIT.

Keywords

FAQs

Last updated on 31 Dec 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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc