Comparing version 0.0.3 to 0.0.4
@@ -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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5576
5
127
1