Socket
Socket
Sign inDemoInstall

botact

Package Overview
Dependencies
16
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.8 to 2.3.9

4

lib/methods/execute.js

@@ -7,3 +7,3 @@ module.exports = function (method, settings, callback = () => {}) {

// TODO: little rework
const item = new (function executionItem() {
const item = new function executionItem () {
this.code = code

@@ -15,3 +15,3 @@ this.callback = callback

})
})()
}()

@@ -18,0 +18,0 @@ const otherTokenItems = this.methods.filter(item => item.access_token !== access_token)

@@ -36,4 +36,4 @@ module.exports = async function (ctx) {

} catch (err) {
console.error(err)
throw err
}
}

@@ -1,66 +0,64 @@

module.exports = async function (req, res) {
const { type, secret } = req.body
const { inital, settings, actions } = this
const { confirmation, secret: token } = settings
module.exports = async function (req, res, callback) {
try {
const { type, secret } = req.body
const { inital, settings, actions } = this
const { confirmation, secret: token } = settings
if (type === 'confirmation') {
res.end(confirmation.toString())
if (type === 'confirmation') {
res.end(confirmation.toString())
return this
} else if (secret && secret !== token) {
res.status(500).end('access denied')
return this
} else if (secret && secret !== token) {
res.status(500).end('access denied')
return this
}
return this
}
const { events, middlewares } = actions
const { object, group_id } = req.body
const { user_id } = object
const forwarded = this.getLastMessage(object)
const { events, middlewares } = actions
const { object, group_id } = req.body
const { user_id } = object
const forwarded = this.getLastMessage(object)
const allowedCtxMethods = ['api', 'reply', 'uploadDocument', 'uploadPhoto', 'uploadCover', 'execute', 'flow', 'redis']
const ctxMethods = Object.keys(this)
.filter(key => allowedCtxMethods.includes(key))
.reduce((obj, key) => {
obj[key] = this[key];
return obj;
}, {});
const allowedCtxMethods = ['api', 'reply', 'uploadDocument', 'uploadPhoto', 'uploadCover', 'execute', 'flow', 'redis']
const ctxMethods = Object.keys(this)
.filter(key => allowedCtxMethods.includes(key))
.reduce((obj, key) => {
obj[key] = this[key]
return obj
}, {})
const ctx = {
...object,
...ctxMethods,
inital,
group_id,
forwarded,
body: object.body || forwarded.body,
scene: {
join: (scene, body, step, instantly) => this.joinScene(ctx, scene, body, step, instantly),
next: (body) => this.nextScene(ctx, body),
leave: () => this.leaveScene(ctx)
},
reply: (message, attachment) => this.reply(user_id, message, attachment),
sendMessage: (user_id, message, attachment) => this.reply(user_id, message, attachment)
}
const ctx = {
...object,
...ctxMethods,
inital,
group_id,
forwarded,
body: object.body || forwarded.body,
scene: {
join: (scene, body, step, instantly) => this.joinScene(ctx, scene, body, step, instantly),
next: (body) => this.nextScene(ctx, body),
leave: () => this.leaveScene(ctx)
},
reply: (message, attachment) => this.reply(user_id, message, attachment),
sendMessage: (user_id, message, attachment) => this.reply(user_id, message, attachment)
}
if (middlewares.length) {
try {
if (middlewares.length) {
await Promise.all(middlewares.map(callback => callback(ctx)))
} catch (error) {
throw new Error(JSON.stringify(error))
}
}
if (type === 'message_new') {
this.handler(ctx)
} else {
const [ event ] = events.filter(({ event }) => event === type)
if (type === 'message_new') {
this.handler(ctx)
} else {
const [ event ] = events.filter(({ event }) => event === type)
if (event) {
event.callback(ctx)
if (event) {
event.callback(ctx)
}
}
res.end('ok')
} catch (err) {
callback(err)
}
res.end('ok')
return this
}

@@ -25,3 +25,3 @@ const axios = require('axios')

{
headers: form.getHeaders(),
headers: form.getHeaders()
})

@@ -28,0 +28,0 @@

@@ -18,3 +18,3 @@ const axios = require('axios')

const form = new FormData()
form.append('photo', fs.createReadStream(file))

@@ -26,3 +26,3 @@

{
headers: form.getHeaders(),
headers: form.getHeaders()
}

@@ -29,0 +29,0 @@ )

{
"name": "botact",
"version": "2.3.8",
"version": "2.3.9",
"description": "Botact enables developers to focus on writing reusable application logic instead of spending time building infrastructure.",

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

@@ -65,3 +65,3 @@ [![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://nodejs.org/en/) [![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://travis-ci.org/bifot/botact/) [![botact](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)

- [.reply(user_id, message, attachment)](#replyuser_id-message-attachment)
- [.listen(req, res)](#listenreq-res)
- [.listen(req, res, callback)](#listenreq-res-callback)

@@ -203,3 +203,3 @@ ### Actions

### .listen(req, res)
### .listen(req, res, callback)

@@ -212,4 +212,5 @@ Start listen [Express](https://github.com/expressjs/express/) server.

listen (
req: any, // Express request, required
res: any // Express response, required
req: any, // Express request, required
res: any // Express response, required
callback: function // Callback for errors
)

@@ -221,3 +222,5 @@ ```

```javascript
bot.listen(req, res)
bot.listen(req, res, (error) => {
res.status(500).json()
})
```

@@ -224,0 +227,0 @@

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

})
})
})

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

})
})
})

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

})
})
})
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