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

botframework

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

botframework - npm Package Compare versions

Comparing version 0.8.3 to 0.9.0

.vscode/launch.json

44

dist/es5/src/facebook/bot.js
"use strict";
var interfaces_1 = require('./interfaces');
var interfaces_1 = require('../interfaces');
var interfaces_2 = require('./interfaces');
var api_1 = require('./api');

@@ -26,5 +27,5 @@ var Promise = require('bluebird');

attachment: {
type: interfaces_1.FB_RESPONSE_ATTACHMENT_TYPE.TEMPLATE,
type: interfaces_2.FB_RESPONSE_ATTACHMENT_TYPE.TEMPLATE,
payload: {
template_type: interfaces_1.FB_RESPONSE_ATTACHMENT_PAYLOAD_TYPE.GENERIC,
template_type: interfaces_2.FB_RESPONSE_ATTACHMENT_PAYLOAD_TYPE.GENERIC,
elements: elements

@@ -51,3 +52,3 @@ }

// console.log('received message ..', JSON.stringify(fbMessage, null, 2));
if (fbMessage.object !== interfaces_1.FB_MESSAGE_TYPE.PAGE)
if (fbMessage.object !== interfaces_2.FB_MESSAGE_TYPE.PAGE)
return Promise.reject('invalid message type');

@@ -78,7 +79,13 @@ for (var _i = 0, _a = fbMessage.entry; _i < _a.length; _i++) {

if (messaging.delivery) {
return (this.botController.delivered) ? this.botController.delivered(user, messaging.delivery, reply) : null;
var request_1 = {
user: user, delivery: messaging.delivery, type: interfaces_1.BOT_REQUEST_TYPE.FACEBOOK
};
return (this.botController.delivered) ? this.botController.delivered(request_1, reply) : null;
}
// console.log('dispatching..');
if (messaging.optin) {
return (this.botController.newUser) ? this.botController.newUser({ user: user, ref: messaging.optin.ref }, reply) : null;
return (this.botController.newUser) ? this.botController.newUser({
user: user, ref: messaging.optin.ref,
type: interfaces_1.BOT_REQUEST_TYPE.FACEBOOK
}, reply) : null;
}

@@ -89,3 +96,4 @@ if (messaging.message) {

user: user,
text: messaging.message.text
text: messaging.message.text,
type: interfaces_1.BOT_REQUEST_TYPE.FACEBOOK
};

@@ -99,3 +107,7 @@ console.log(JSON.stringify(textMessage));

}
return (this.botController.catchAll) ? this.botController.catchAll(user, messaging, reply) : null;
var request = {
user: user, raw: messaging,
type: interfaces_1.BOT_REQUEST_TYPE.FACEBOOK
};
return (this.botController.catchAll) ? this.botController.catchAll(request, reply) : null;
};

@@ -107,17 +119,18 @@ FacebookBot.prototype.dispatchAttachmentMessage = function (messaging, user) {

switch (attachment.type) {
case interfaces_1.FB_ATTACHMENT_TYPE.IMAGE:
case interfaces_2.FB_ATTACHMENT_TYPE.IMAGE:
var imageMessage = {
user: user, link: { url: attachment.payload.url }
user: user, link: { url: attachment.payload.url },
type: interfaces_1.BOT_REQUEST_TYPE.FACEBOOK
};
this.botController.imageMessage(imageMessage, reply) || null;
break;
case interfaces_1.FB_ATTACHMENT_TYPE.LOCATION:
case interfaces_2.FB_ATTACHMENT_TYPE.LOCATION:
var location_1 = {
user: user, location: { coordinates: attachment.payload.coordinates }
user: user, location: { coordinates: attachment.payload.coordinates }, type: interfaces_1.BOT_REQUEST_TYPE.FACEBOOK
};
(this.botController.locationMessage) ? this.botController.locationMessage(location_1, reply) : null;
break;
case interfaces_1.FB_ATTACHMENT_TYPE.FALLBACK:
case interfaces_2.FB_ATTACHMENT_TYPE.FALLBACK:
if (attachment.payload === null) {
var link = { user: user, link: { url: attachment.url, title: attachment.title } };
var link = { user: user, link: { url: attachment.url, title: attachment.title }, type: interfaces_1.BOT_REQUEST_TYPE.FACEBOOK };
(this.botController.linkMessage) ? this.botController.linkMessage(link, reply) : null;

@@ -127,3 +140,4 @@ }

default:
(this.botController.catchAll) ? this.botController.catchAll(user, messaging, reply) : null;
var request = { user: user, raw: messaging, type: interfaces_1.BOT_REQUEST_TYPE.FACEBOOK };
(this.botController.catchAll) ? this.botController.catchAll(request, reply) : null;
break;

@@ -130,0 +144,0 @@ }

@@ -10,6 +10,2 @@ export interface IBotUser {

}
export interface ITextMessage {
user: IBotUser;
text: string;
}
export interface ILink {

@@ -29,18 +25,2 @@ url: string;

}
export interface ILinkMessage {
user: IBotUser;
link: ILink;
}
export interface ILocationMessage {
user: IBotUser;
location: ILocation;
}
export interface IImageMessage {
user: IBotUser;
link: IImage;
}
export interface INewUserMessage {
user: IBotUser;
ref: string;
}
export declare class BOT_REPLY_LIST_ACTION_TYPE {

@@ -62,2 +42,15 @@ static LINK: string;

}
export declare class BOT_REQUEST_TYPE {
static FACEBOOK: string;
}
export interface IBotRequest {
user: IBotUser;
location?: ILocation;
link?: IImage;
ref?: string;
image?: IImage;
text?: string;
raw?: any;
type: BOT_REQUEST_TYPE;
}
export interface IBotReply {

@@ -67,10 +60,18 @@ text(text: string): void;

}
export interface IDeliveryMessage {
user: IBotUser;
delivery: any;
}
export interface IUnknownMessage {
user: IBotUser;
delivery: any;
}
export interface IBotController {
newUser?(msg: INewUserMessage, reply: IBotReply): void;
textMessage?(textMessage: ITextMessage, reply: IBotReply): void;
imageMessage?(imageMessage: IImageMessage, reply: IBotReply): void;
linkMessage?(linkMessage: ILinkMessage, reply: IBotReply): void;
locationMessage?(locationMessage: ILocationMessage, reply: IBotReply): void;
delivered?(user: IBotUser, delivery: Object, reply: IBotReply): void;
catchAll?(user: IBotUser, msg: Object, reply: IBotReply): void;
newUser?(request: IBotRequest, reply: IBotReply): void;
textMessage?(request: IBotRequest, reply: IBotReply): void;
imageMessage?(request: IBotRequest, reply: IBotReply): void;
linkMessage?(request: IBotRequest, reply: IBotReply): void;
locationMessage?(request: IBotRequest, reply: IBotReply): void;
delivered?(request: IBotRequest, reply: IBotReply): void;
catchAll?(request: IBotRequest, reply: IBotReply): void;
}

@@ -77,0 +78,0 @@ export interface IBotSettings {

@@ -15,4 +15,14 @@ "use strict";

exports.BOT_REPLY_LIST_ACTION_TYPE = BOT_REPLY_LIST_ACTION_TYPE;
// export interface IBotReplyList {
// elements: Array<IBotReplyListItem>;
// }
var BOT_REQUEST_TYPE = (function () {
function BOT_REQUEST_TYPE() {
}
BOT_REQUEST_TYPE.FACEBOOK = 'facebook';
return BOT_REQUEST_TYPE;
}());
exports.BOT_REQUEST_TYPE = BOT_REQUEST_TYPE;
__export(require('./bot'));
__export(require('./facebook'));
//# sourceMappingURL=interfaces.js.map
{
"name": "botframework",
"version": "0.8.3",
"version": "0.9.0",
"description": "Framework for messaging bots",

@@ -43,2 +43,2 @@ "main": "./dist/es5/src/bot.js",

}
}
}

@@ -1,2 +0,2 @@

import {IBotController, IBotSettings, IBotUser, ITextMessage, IBotReply, IBotReplyListItem} from '../interfaces'
import {IBotController, BOT_REQUEST_TYPE, IBotSettings, IBotUser, IBotRequest, IBotReply, IBotReplyListItem} from '../interfaces'
import {IFbResponse, IFbCallback, FB_RESPONSE_ATTACHMENT_PAYLOAD_TYPE, FB_RESPONSE_ATTACHMENT_TYPE, IFbMessaging, FB_ATTACHMENT_TYPE, FB_MESSAGE_TYPE} from './interfaces';

@@ -70,13 +70,20 @@ import {FacebookApi, IFacebookProfile} from './api';

if (messaging.delivery) {
return (this.botController.delivered) ? this.botController.delivered(user, messaging.delivery, reply) : null;
let request = {
user, delivery: messaging.delivery, type: BOT_REQUEST_TYPE.FACEBOOK
};
return (this.botController.delivered) ? this.botController.delivered(request, reply) : null;
}
// console.log('dispatching..');
if (messaging.optin) {
return (this.botController.newUser) ? this.botController.newUser({user, ref: messaging.optin.ref}, reply) : null;
return (this.botController.newUser) ? this.botController.newUser({
user, ref: messaging.optin.ref,
type: BOT_REQUEST_TYPE.FACEBOOK
}, reply) : null;
}
if (messaging.message) {
if (messaging.message.text) {
let textMessage: ITextMessage = {
let textMessage: IBotRequest = {
user,
text: messaging.message.text
text: messaging.message.text,
type: BOT_REQUEST_TYPE.FACEBOOK
}

@@ -90,3 +97,7 @@ console.log(JSON.stringify(textMessage));

}
return (this.botController.catchAll) ? this.botController.catchAll(user, messaging, reply) : null;
let request = {
user, raw: messaging,
type: BOT_REQUEST_TYPE.FACEBOOK
}
return (this.botController.catchAll) ? this.botController.catchAll(request, reply) : null;
}

@@ -101,3 +112,4 @@

let imageMessage = {
user, link: {url: attachment.payload.url}
user, link: {url: attachment.payload.url},
type: BOT_REQUEST_TYPE.FACEBOOK
};

@@ -108,3 +120,3 @@ this.botController.imageMessage(imageMessage, reply) || null;

let location = {
user, location: {coordinates: attachment.payload.coordinates}
user, location: {coordinates: attachment.payload.coordinates}, type: BOT_REQUEST_TYPE.FACEBOOK
};

@@ -115,3 +127,3 @@ (this.botController.locationMessage) ? this.botController.locationMessage(location, reply) : null;

if (attachment.payload === null) {
let link = {user, link: {url: attachment.url, title: attachment.title}};
let link = {user, link: {url: attachment.url, title: attachment.title}, type: BOT_REQUEST_TYPE.FACEBOOK };
(this.botController.linkMessage) ? this.botController.linkMessage(link, reply) : null;

@@ -121,3 +133,4 @@ }

default:
(this.botController.catchAll) ? this.botController.catchAll(user, messaging, reply) : null;
let request = {user, raw: messaging, type: BOT_REQUEST_TYPE.FACEBOOK};
(this.botController.catchAll) ? this.botController.catchAll(request, reply) : null;
break;

@@ -124,0 +137,0 @@ }

@@ -12,6 +12,2 @@

export interface ITextMessage {
user: IBotUser;
text: string;
}

@@ -36,23 +32,4 @@ export interface ILink {

export interface ILinkMessage {
user: IBotUser;
link: ILink;
}
export interface ILocationMessage {
user: IBotUser;
location: ILocation;
}
export interface IImageMessage {
user: IBotUser;
link: IImage;
}
export interface INewUserMessage {
user: IBotUser;
ref: string;
}
// enum

@@ -81,3 +58,17 @@ // currently very aligned to facebook

// }
export class BOT_REQUEST_TYPE {
static FACEBOOK = 'facebook';
}
export interface IBotRequest {
user: IBotUser;
location?: ILocation;
link?: IImage;
ref?: string;
image?: IImage;
text?: string;
raw?: any;
type: BOT_REQUEST_TYPE; // facebook|slack...
}
export interface IBotReply {

@@ -88,10 +79,21 @@ text(text: string): void;

export interface IDeliveryMessage {
user: IBotUser;
delivery: any;
}
export interface IUnknownMessage {
user: IBotUser;
delivery: any;
}
export interface IBotController {
newUser?(msg: INewUserMessage, reply: IBotReply): void;
textMessage?(textMessage: ITextMessage, reply: IBotReply): void;
imageMessage?(imageMessage: IImageMessage, reply: IBotReply): void;
linkMessage?(linkMessage: ILinkMessage, reply: IBotReply): void;
locationMessage?(locationMessage: ILocationMessage, reply: IBotReply): void;
delivered?(user: IBotUser, delivery: Object, reply: IBotReply): void;
catchAll?(user: IBotUser, msg: Object, reply: IBotReply): void;
newUser?(request: IBotRequest, reply: IBotReply): void;
textMessage?(request: IBotRequest, reply: IBotReply): void;
imageMessage?(request: IBotRequest, reply: IBotReply): void;
linkMessage?(request: IBotRequest, reply: IBotReply): void;
locationMessage?(request: IBotRequest, reply: IBotReply): void;
delivered?(request: IBotRequest, reply: IBotReply): void;
catchAll?(request: IBotRequest, reply: IBotReply): void;
}

@@ -98,0 +100,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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