23 end |
23 end |
24 |
24 |
25 bot:hook("commands/issue", function (command) |
25 bot:hook("commands/issue", function (command) |
26 local issue_id = tonumber(command.param); |
26 local issue_id = tonumber(command.param); |
27 if not issue_id then return; end |
27 if not issue_id then return; end |
28 local current_conf = conf[command.room and command.room.jid or "default"]; |
28 local current_conf = conf[command.room and command.room.jid] or conf; |
29 if not current_conf then return end |
29 if not current_conf.user then return end |
30 assert(http.request(issue_url(issue_id), ex, function (issue, code) |
30 assert(http.request(get_issue_url(issue_id), ex, function (issue, code) |
31 if code > 400 then |
31 if code > 400 then |
32 return command:reply("HTTP Error "..code.." :("); |
32 return command:reply("HTTP Error "..code.." :("); |
33 end |
33 end |
34 issue = issue and json.decode(issue); |
34 issue = issue and json.decode(issue); |
35 if not issue then |
35 if not issue then |
36 return command:reply("Got invalid JSON back :("); |
36 return command:reply("Got invalid JSON back :("); |
37 end |
37 end |
38 command:reply(("%s #%d\n%s"):format(issue.title, issue.number issue.html_url)); |
38 command:reply(("%s #%d\n%s"):format(issue.title, issue.number, issue.html_url)); |
39 end)); |
39 end)); |
40 return true; |
40 return true; |
41 end); |
41 end); |
42 |
42 |
43 local function check_for_issue_id(message) |
43 local function check_for_issue_id(message) |