Socket
Socket
Sign inDemoInstall

botact

Package Overview
Dependencies
156
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.8.4 to 1.8.5

6

lib/methods/listen.js

@@ -44,6 +44,6 @@ module.exports = async function (req, res) {

} else {
const callback = events[type]
const [ event ] = events.filter(({ event }) => event === type)
if (callback !== undefined) {
callback(ctx)
if (event !== undefined) {
event.callback(ctx)
}

@@ -50,0 +50,0 @@ }

{
"name": "botact",
"version": "1.8.4",
"version": "1.8.5",
"description": "A framework for creating VK bots on callback API.",

@@ -5,0 +5,0 @@ "main": "index.js",

[![botact](https://img.shields.io/npm/v/botact.svg?style=flat-square)](https://www.npmjs.com/package/botact/)
[![botact](https://img.shields.io/node/v/botact.svg?style=flat-square)](https://www.npmjs.com/package/botact/)
[![botact](https://img.shields.io/npm/dm/botact.svg?style=flat-square)](https://www.npmjs.com/package/botact/)
[![botact](https://img.shields.io/travis/bifot/botact.svg?branch=master&style=flat-square)](https://www.npmjs.com/package/botact/)
[![botact](https://img.shields.io/npm/dm/botact.svg?style=flat-square)](https://www.npmjs.com/package/botact/)
[![botact](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)

@@ -6,0 +6,0 @@

@@ -17,2 +17,4 @@ const { expect } = require('chai')

})
this.sendRequest = (body) => this.bot.listen({ body }, { end() {} })
})

@@ -64,6 +66,13 @@

const command = 'example'
const callback = () => {}
const callback = (ctx) => expect(ctx).to.be.a('object')
this.bot.command(command, callback)
this.sendRequest({
type: 'message_new',
object: {
body: command
}
})
const stringifyCommands = this.bot.actions.commands

@@ -78,6 +87,13 @@ .map(({ command, callback }) => JSON.stringify({ command, callback: callback.toString() }))

const command = /example/i
const callback = () => {}
const callback = (ctx) => expect(ctx).to.be.a('object')
this.bot.hears(command, callback)
this.sendRequest({
type: 'message_new',
object: {
body: command.toString()
}
})
const stringifyCommands = this.bot.actions.hears

@@ -90,10 +106,37 @@ .map(({ command, callback }) => JSON.stringify({ command: command.toString(), callback: callback.toString() }))

it('add reserved command', () => {
const callback = () => {}
it('add on', () => {
const callback = (ctx) => expect(ctx).to.be.a('object')
this.bot.on(callback)
this.sendRequest({
type: 'message_new',
object: {
body: Math.random()
}
})
expect(this.bot.actions.on).eq(callback)
})
it('add event', () => {
const event = 'group_join'
const callback = (ctx) => expect(ctx).to.be.a('object')
this.bot.event(event, callback)
this.sendRequest({
type: event,
object: {
user_id: Math.random()
}
})
const stringifyEvents = this.bot.actions.events
.map(({ command, callback }) => JSON.stringify({ event, callback: callback.toString() }))
const stringifyEvent = JSON.stringify({ event, callback: callback.toString() })
expect(stringifyEvents).to.include(stringifyEvent)
})
it('add scene', () => {

@@ -100,0 +143,0 @@ const scene = 'simple'

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