16 |
16 |
17 local function issue_url(number) |
17 local function issue_url(number) |
18 base_path[5] = number; |
18 base_path[5] = number; |
19 base_url.path = url.build_path(base_path); |
19 base_url.path = url.build_path(base_path); |
20 local url = url.build(base_url); |
20 local url = url.build(base_url); |
21 print("url:", url); |
|
22 return url; |
21 return url; |
23 end |
22 end |
24 |
23 |
25 bot:hook("commands/issue", function (command) |
24 bot:hook("commands/issue", function (command) |
26 local issue_id = tonumber(command.param); |
25 local issue_id = tonumber(command.param); |
27 if not issue_id then return; end |
26 if not issue_id then return; end |
28 print(issue_id); |
|
29 assert(http.request(issue_url(issue_id), ex, function (issue, code) |
27 assert(http.request(issue_url(issue_id), ex, function (issue, code) |
30 if code > 400 then |
28 if code > 400 then |
31 return command:reply("HTTP Error "..code.." :("); |
29 return command:reply("HTTP Error "..code.." :("); |
32 end |
30 end |
33 issue = issue and json.decode(issue); |
31 issue = issue and json.decode(issue); |