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