node-vk-bot-api
Advanced tools
Comparing version 1.1.0 to 1.1.1
const API = require('../index') | ||
const { settings } = require('../config') | ||
const { token } = require('../config') | ||
const bot = new API(settings) | ||
const bot = new API(token) | ||
bot.command('start', ({ reply }) => reply('This is start!')) | ||
bot.hears('car', ({ reply }) => reply('I love Tesla!')) | ||
bot.hears(/(car|tesla)/, ({ reply }) => reply('I love Tesla!')) | ||
@@ -10,0 +10,0 @@ bot.on(({ reply }) => reply('What?')) |
const executeHandler = require('./utils/executeHandler') | ||
module.exports = class Bot { | ||
constructor (settings) { | ||
if (!settings) { | ||
throw 'Settings not found' | ||
} else if (!settings.token) { | ||
constructor (token) { | ||
if (!token) { | ||
throw 'Token is required' | ||
} | ||
this.settings = settings | ||
this.token = token | ||
this.methods = {} | ||
@@ -13,0 +11,0 @@ this.actions = { commands: {}, hears: {}, on: {} } |
module.exports = function (command, callback) { | ||
const list = typeof command === 'object' && !/\/[\S]{1,}\/[a-z]{1,2}/.test(command) | ||
const list = typeof command === 'object' && !(command instanceof RegExp) | ||
? command : [command] | ||
@@ -4,0 +4,0 @@ const string = list |
@@ -10,3 +10,3 @@ const rp = require('request-promise') | ||
lp_version: 2, | ||
access_token: this.settings.token, | ||
access_token: this.token, | ||
v: 5.65 | ||
@@ -80,3 +80,3 @@ }) | ||
v: 5.67 | ||
}, this.settings.token, (data) => { | ||
}, this.token, (data) => { | ||
resolve(this.getLastMessage(data.items[0])) | ||
@@ -83,0 +83,0 @@ }) |
@@ -6,5 +6,5 @@ module.exports = function (peer, message, attachment) { | ||
attachment: attachment | ||
}, this.settings.token, null) | ||
}, this.token, null) | ||
return this | ||
} |
{ | ||
"name": "node-vk-bot-api", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "API for VK bots on long poll.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -19,9 +19,7 @@ [![node-vk-bot-api](https://img.shields.io/npm/v/node-vk-bot-api.svg?style=flat-square)](https://www.npmjs.com/package/node-vk-bot-api/) | ||
const bot = new API({ | ||
token: process.env.TOKEN | ||
}) | ||
const bot = new API(process.env.TOKEN) | ||
bot.command('start', ({ reply }) => reply('This is start!')) | ||
bot.hears('car', ({ reply }) => reply('I love Tesla!')) | ||
bot.hears(/(car|tesla)/, ({ reply }) => reply('I love Tesla!')) | ||
@@ -45,3 +43,3 @@ bot.on(({ reply }) => reply('What?')) | ||
|:-----------|:---------:| ---------:| | ||
| options | object | yes | | ||
| token | string | yes | | ||
@@ -48,0 +46,0 @@ Create bot. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
14324
300
121