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

botstats

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

botstats - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

old.js

90

botstats.js

@@ -1,5 +0,4 @@

var request = require('request');
var querystring = require('querystring');
var http = require('https');
// production
var url = 'https://api.botstats.co/api/bot/post';

@@ -9,3 +8,3 @@ module.exports = function( token ) {

receive: function (event, next) {
var sendData = {
var data = querystring.stringify({
source: event.source,

@@ -16,18 +15,25 @@ type: "incoming",

message: event.text,
}
})
var options = {
method: 'post',
body: sendData,
json: true,
url: url,
host: 'https://api.botstats.co/api/bot',
port: null,
path: '/post',
method: 'POST',
headers: {
'Authorization': 'Bearer ' + token
'authorization': 'Bearer ' + token,
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(data)
}
}
request(options, function(error, result){
if (error){
console.log("error", error)
}
})
};
var req = http.request(options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log("body: " + chunk);
});
});
req.write(data);
req.end();
next();

@@ -37,33 +43,31 @@ },

var sendData = {
source: event.source,
type: "outgoing",
profile: event.address.user,
conversation: event.address.conversation,
message: messageType(),
}
var data = querystring.stringify({
source: event.source,
type: "outgoing",
profile: event.address.user,
conversation: event.address.conversation,
message: messageType()
});
function messageType() {
if (event.text) {
return event.text
} else if ( event.attachments) {
return "Sent Attachments"
} else {
return "Unknown message type"
}
}
var options = {
method: 'post',
body: sendData,
json: true,
url: url,
host: 'https://api.botstats.co/api/bot',
port: null,
path: '/post',
method: 'POST',
headers: {
'Authorization': 'Bearer ' + token
'authorization': 'Bearer ' + token,
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(data)
}
}
request(options, function(error, result){
if (error){
console.log("error", error)
}
})
};
var req = http.request(options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log("body: " + chunk);
});
});
req.write(data);
req.end();
next();

@@ -70,0 +74,0 @@ }

{
"name": "botstats",
"version": "0.0.3",
"version": "0.0.4",
"description": "Middleware for botframework",

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

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