# HG changeset patch # User Kim Alvefur # Date 1311117071 -7200 # Node ID ce687757ce3dcd5c365654371208c88f9f84b820 # Parent 4a25cd97711db3487be57377fdda63aea169e96f plugins.xeps: Check for exact matches on shortnames. diff -r 4a25cd97711d -r ce687757ce3d plugins/xeps.lua --- a/plugins/xeps.lua Wed Jul 20 01:04:31 2011 +0200 +++ b/plugins/xeps.lua Wed Jul 20 01:11:11 2011 +0200 @@ -1,5 +1,5 @@ local parse_xeps, xeps_updated_at; -local xeps = {}; +local xeps, xeps_short = {}, {}; function riddim.plugins.xeps(bot) require "net.httpclient_listener"; @@ -29,7 +29,9 @@ function handle_xep_command(command) local xepnum = command.param; if not xepnum then return "Please supply an XEP number or a search string :)"; end - if not tonumber(xepnum) then -- Search for an XEP + if xeps_short[xepnum:lower()] then + xepnum = xeps_short[xepnum:lower()]; + elseif not tonumber(xepnum) then -- Search for an XEP if xepnum:match("^(%d+) ex%S* (%d+)$") then local num, example = xepnum:match("^(%d+) ex%S* (%d+)$"); return "http://xmpp.org/extensions/xep-"..string.rep("0", 4-num:len())..num..".html#example-"..tostring(example); @@ -78,7 +80,14 @@ currxep[k] = v; end xeps[currxep.number] = { }; - for k, v in pairs(currxep) do xeps[currxep.number][k] = v end + for k, v in pairs(currxep) do + xeps[currxep.number][k] = v; + if xeps_short[currxep.shortname] == nil then + xeps_short[currxep.shortname] = currxep.number; + elseif xeps_short[currxep.shortname] then + xeps_short[currxep.shortname] = false; -- kill dupes + end + end end xeps["0028"] = { number = "0028", name = "XSF Plans for World Domination", type="Top Secret", status = "Hidden", updated = "Work ongoing" }; return true;