Pass whom when creating the say function;
This commit is contained in:
parent
e5840d521c
commit
4c9a1e381e
8
index.js
8
index.js
@ -143,9 +143,10 @@ var handlers = {
|
||||
|
||||
};
|
||||
|
||||
function say(msgs) {
|
||||
if (msgs) {
|
||||
function makeSay(body) {
|
||||
var whom = hookToChannel[body.object_kind] || [];
|
||||
return function say(msgs) {
|
||||
if (msgs) {
|
||||
if (msgs instanceof Array) {
|
||||
for (var i = 0; i < msgs.length; i++)
|
||||
client.say(whom, msgs[i]);
|
||||
@ -153,6 +154,7 @@ function say(msgs) {
|
||||
client.say(whom, msgs);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
app.post('/', function(req, res) {
|
||||
@ -160,7 +162,7 @@ app.post('/', function(req, res) {
|
||||
|
||||
var msgs = null;
|
||||
if (body.object_kind && handlers[body.object_kind])
|
||||
handlers[body.object_kind](body, say);
|
||||
handlers[body.object_kind](body, makeSay(body));
|
||||
else
|
||||
console.log("Unexpected object_kind:", body.object_kind);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user