# HG changeset patch # User Kim Alvefur # Date 1438976702 -7200 # Node ID 5b03c71d05f0b74a56c099149e7126885f79f2a0 # Parent 6c977fbf6d0bfc481e5d9c2bf44983d43099e28c plugins.github: Support per-room configuration diff -r 6c977fbf6d0b -r 5b03c71d05f0 plugins/github.lua --- a/plugins/github.lua Fri Aug 07 21:44:21 2015 +0200 +++ b/plugins/github.lua Fri Aug 07 21:45:02 2015 +0200 @@ -6,7 +6,6 @@ local conf = bot.config.github; local base_url = url.parse("https://api.github.com/repos/x/y/issues/123"); local base_path = url.parse_path(base_url.path); - base_path[2], base_path[3] = conf.user, conf.project; local ex = { headers = { @@ -14,7 +13,9 @@ }; }; - local function issue_url(number) + local function get_issue_url(conf, number) + base_path[2] = conf.user; + base_path[3] = conf.repo or conf.project; base_path[5] = number; base_url.path = url.build_path(base_path); local url = url.build(base_url); @@ -24,6 +25,8 @@ bot:hook("commands/issue", function (command) local issue_id = tonumber(command.param); if not issue_id then return; end + local current_conf = conf[command.room and command.room.jid or "default"]; + if not current_conf then return end assert(http.request(issue_url(issue_id), ex, function (issue, code) if code > 400 then return command:reply("HTTP Error "..code.." :(");