@@ -1,6 +1,6 @@ |
||
| 1 | 1 |
{
|
| 2 | 2 |
"name": "hubot-multi-adapter", |
| 3 |
- "version": "0.3.2", |
|
| 3 |
+ "version": "0.3.3", |
|
| 4 | 4 |
"description": "A Hubot adapter that can receive messages thru socket.io or telegram", |
| 5 | 5 |
"main": "src/multi-adapter", |
| 6 | 6 |
"scripts": {
|
@@ -87,13 +87,13 @@ class MultiAdapter extends Adapter |
||
| 87 | 87 |
# General Webhook |
| 88 | 88 |
app.post '/webhook', (req, res) => |
| 89 | 89 |
console.log(req.body) |
| 90 |
- if(req.body.user != undefined){
|
|
| 91 |
- if(req.body.user.room && req.body.user.service && req.body.user.first_name && req.body.user.last_name && req.body.user.username && req.body.user.msg_type){
|
|
| 90 |
+ if req.body.user != undefined |
|
| 91 |
+ if req.body.user.room && req.body.user.service && req.body.user.first_name && req.body.user.last_name && req.body.user.username && req.body.user.msg_type |
|
| 92 | 92 |
chat_id = req.body.user.room |
| 93 | 93 |
# Get username |
| 94 | 94 |
user_name = req.body.user.first_name + " " + req.body.user.last_name |
| 95 | 95 |
command = req.body.command |
| 96 |
- @robot.brain.set 'log_id_' + chat_id, new Date().getUTCMilliseconds(); |
|
| 96 |
+ @robot.brain.set 'log_id_' + chat_id, new Date().getUTCMilliseconds() |
|
| 97 | 97 |
user = @userForId chat_id, name: user_name, room: chat_id |
| 98 | 98 |
console.log("Webhook received from " + user_name + " with command:" )
|
| 99 | 99 |
console.log(command) |
@@ -105,13 +105,10 @@ class MultiAdapter extends Adapter |
||
| 105 | 105 |
user.msg_type = req.body.user.msg_type |
| 106 | 106 |
@receive new TextMessage user, text |
| 107 | 107 |
res.status(400).send({"message" : "received"})
|
| 108 |
- } else {
|
|
| 108 |
+ else |
|
| 109 | 109 |
res.status(400).send({"message" : "The user object has mising properties. Follow instruction on https://github.com/jamesperet/hubot-multi-adaptor"})
|
| 110 |
- } |
|
| 111 |
- } else {
|
|
| 110 |
+ else |
|
| 112 | 111 |
res.status(200).send({"message" : "Please check the body of your request. Follow instruction on https://github.com/jamesperet/hubot-multi-adaptor"})
|
| 113 |
- } |
|
| 114 |
- |
|
| 115 | 112 |
res.end() |
| 116 | 113 |
|
| 117 | 114 |
@emit 'connected' |