|
|
@@ -78,8 +78,28 @@ class MultiAdapter extends Adapter
|
78
|
78
|
user.first_name = req.body['message[from][first_name]']
|
79
|
79
|
user.last_name = req.body['message[from][last_name]']
|
80
|
80
|
user.username = req.body['message[from][username]']
|
|
81
|
+ user.room = chat_id
|
81
|
82
|
@receive new TextMessage user, text
|
82
|
83
|
res.end()
|
|
84
|
+
|
|
85
|
+ app.post '/webhook', (req, res) =>
|
|
86
|
+ console.log(req.body)
|
|
87
|
+ chat_id = req.body.user.room
|
|
88
|
+ # Get username
|
|
89
|
+ user_name = req.body.user.first_name + " " + req.body.user.last_name]
|
|
90
|
+ command = req.body.command
|
|
91
|
+ @robot.brain.set 'log_id_' + chat_id, new Date().getUTCMilliseconds();
|
|
92
|
+ user = @userForId chat_id, name: user_name, room: chat_id
|
|
93
|
+ console.log("Webhook received from " + user_name + " with command:" )
|
|
94
|
+ console.log(command)
|
|
95
|
+ user.service = "webhook"
|
|
96
|
+ user.first_name = req.body.user.first_name
|
|
97
|
+ user.last_name = req.body.user.last_name
|
|
98
|
+ user.username = req.body.user.username
|
|
99
|
+ user.room = chat_id
|
|
100
|
+ @receive new TextMessage user, text
|
|
101
|
+ res.end()
|
|
102
|
+
|
83
|
103
|
@emit 'connected'
|
84
|
104
|
|
85
|
105
|
exports.use = (robot) ->
|