Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

botly

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

botly - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

13

lib/Botly.js

@@ -335,2 +335,3 @@ 'use strict';

_handleUserMessage.call(this, message);
_handleEcho.call(this, message);
}, this);

@@ -355,3 +356,3 @@ }, this);

function _handlePostback(message) {
if (message.postback || (message.message && message.message.quick_reply)) {
if (message.postback || (message.message && !message.message.is_echo && message.message.quick_reply)) {
let postback = (message.postback && message.postback.payload) || message.message.quick_reply.payload;

@@ -371,7 +372,7 @@ this.emit('postback', message.sender.id, message, postback);

var value;
if (message.message && message.message.text && !message.message.quick_reply) {
if (message.message && !message.message.is_echo && message.message.text && !message.message.quick_reply) {
value = {text: message.message.text};
}
if (message.message && message.message.attachments) {
if (message.message && !message.message.is_echo && message.message.attachments) {
let attachments = {};

@@ -392,2 +393,8 @@ message.message.attachments.forEach((attachment) => {

function _handleEcho(message) {
if (message.message && message.message.is_echo) {
this.emit('echo', message.sender.id, message, message.message);
}
}
function _clone(obj) {

@@ -394,0 +401,0 @@ return JSON.parse(JSON.stringify(obj));

{
"name": "botly",
"version": "1.1.4",
"version": "1.1.5",
"description": "Simple Facebook Messenger Bot API",

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

@@ -295,2 +295,6 @@ <img src="https://raw.githubusercontent.com/Askrround/botly/master/botly_logo.png" width="250" height="250" />

botly.on("echo", (sender, message, content) => {
/* track it */
});
botly.on("account_link", (sender, message, link) => {

@@ -305,2 +309,6 @@ /**

#### version 1.1.5
- fixed duplicate messages on echo
- added echo event support
#### version 1.1.4

@@ -307,0 +315,0 @@ - added support for account linking functionality (event, getPSID)

@@ -158,2 +158,54 @@ var expect = require('chai').expect;

it('should handle echo messages', done => {
var botly = new Botly({
accessToken: 'myToken',
verifyToken: 'myVerifyToken',
webHookPath: '/webhook',
notificationType: Botly.CONST.NOTIFICATION_TYPE.NO_PUSH
});
var router = botly.router();
botly.on('echo', (id, message, content) => {
expect(id).to.equal(USER_ID);
expect(content.text).to.equal('some text');
done();
});
var response = http.createResponse();
var request = http.createRequest({
method: 'POST',
url: '/webhook',
body: {
'object': 'page',
'entry': [
{
'id': PAGE_ID,
'time': 12341,
'messaging': [
{
'sender': {
'id': USER_ID
},
'recipient': {
'id': PAGE_ID
},
'timestamp': 1234567890,
'message': {
'mid': 'mid.1457764197618:41d102a3e1ae206a38',
'seq': 73,
'text': 'some text',
'is_echo': true
}
}
]
}
]
}
});
router.handle(request, response);
});
it('should emit error when there is one', done => {

@@ -160,0 +212,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc