Fix mcabber_bts
authorMikael Berthe <mikael@lilotux.net>
Mon, 12 Oct 2015 12:42:27 +0200
changeset 72 01a4b9048880
parent 71 63ee968309d4
child 73 2ca07b5226c1
Fix mcabber_bts
mcbot/cmds/mcabber_bts.lua
--- a/mcbot/cmds/mcabber_bts.lua	Fri Apr 03 22:49:15 2015 +0200
+++ b/mcbot/cmds/mcabber_bts.lua	Mon Oct 12 12:42:27 2015 +0200
@@ -23,7 +23,7 @@
     num = tonumber(num);
     if not num then return nil end
     local issue = {}
-    local btsurl = "https://bitbucket.org/McKael/mcabber-crew/issue/"
+    local btsurl = "https://bitbucket.org/McKael/mcabber-crew/issues/"
 
     issue.id = tostring(num)
     issue.url = btsurl..issue.id.."/"
@@ -31,16 +31,21 @@
     if not data then return nil end
     local title = data:match("#"..issue.id.."%s*-%s*(.*)%s*&mdash;")
     if not title then return nil end
-    issue.title = title:gsub("&quot;", "\""):gsub("&amp;", "&")
+    issue.title = title
+    issue.title = issue.title:gsub("&quot;", "\""):gsub("&amp;", "&")
     issue.title = issue.title:gsub("&lt;", "<"):gsub("&gt;", ">")
     issue.title = issue.title:gsub("&#39;", "'")
+    issue.title = issue.title:gsub("[%s\n]+$", "") -- trailing newlines
 
     -- Get Status
-    item = data:match("Status:%s*</td>%s*<td [^>]*>(.-)</td>")
+    item = data:match('<a href="[^"]+/issues%?status=(%w+)"')
     if item then issue.status = item end
     -- Get Type
-    item = data:match("Type:%s*</td>%s*<td [^>]*>(.-)</td>")
+    item = data:match('<a href="[^"]+/issues%?kind=(%w+)"')
     if item then issue.type = item end
+    -- Get Priority
+    item = data:match('<a href="[^"]+/issues%?priority=(%w+)"')
+    if item then issue.priority = item end
 
     return issue
 end
@@ -67,6 +72,9 @@
     if issue.type then
         result = result .. "Type: " .. issue.type .. "\n"
     end
+    if issue.type then
+        result = result .. "Priority: " .. issue.priority .. "\n"
+    end
     return result .. "URL: <"..tostring(issue.url)..">"
 end