link as pattern in urban_dictionary.lua

This commit is contained in:
Akamaru 2015-07-13 23:00:24 +02:00
parent b2ea23bfb2
commit b95afbb819

View File

@ -1,5 +1,5 @@
function getUrbanDictionary(text) function getUrbanDictionary(text)
local topic = string.match(text, "/ud (.+)") local topic = string.match(text, "/ud (.+)") or string.match(text, "http://([A-Za-z0-9-_-]+).urbanup.com/")
topic = url_encode(topic) topic = url_encode(topic)
b = http.request("http://api.urbandictionary.com/v0/define?term=" .. topic) b = http.request("http://api.urbandictionary.com/v0/define?term=" .. topic)
res = json:decode(b) res = json:decode(b)
@ -34,6 +34,8 @@ end
return { return {
description = "Zeigt eine Urban Dictionary Definition", description = "Zeigt eine Urban Dictionary Definition",
usage = {"/ud [Begriff]"}, usage = {"/ud [Begriff]"},
patterns = {"^/ud (.*)$"}, patterns = {"^/ud (.*)$",
"^http://([A-Za-z0-9-_-]+).urbanup.com/"
},
run = run run = run
} }