From 5dde8edad8fb64a24b282c06e8d5dc979aa26ef0 Mon Sep 17 00:00:00 2001 From: Akamaru Date: Sun, 21 Jun 2015 22:00:19 +0200 Subject: [PATCH] url-fix for wiki.lua --- plugins/wiki.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/wiki.lua b/plugins/wiki.lua index e929a0e..0e0a0bb 100644 --- a/plugins/wiki.lua +++ b/plugins/wiki.lua @@ -2,6 +2,17 @@ local socket = require "socket" local JSON = require "cjson" +local decodetext +do + local char, gsub, tonumber = string.char, string.gsub, tonumber + local function _(hex) return char(tonumber(hex, 16)) end + + function decodetext(s) + s = gsub(s, '%%(%x%x)', _) + return s + end +end + local wikiusage = { "/wiki [Begriff]: Poste Artikel von der deutschen Wikipedia", "/wiki(lang) [Begriff]: Poste Artikel aus anderer Sprache. Beispiel: /wikien Hello", @@ -88,6 +99,7 @@ end -- extract intro passage in wiki page function Wikipedia:wikintro(text, lang) + local text = decodetext(text) local result = self:loadPage(text, lang, true, true) if result and result.query then @@ -160,7 +172,6 @@ local function run(msg, matches) if search then result = Wikipedia:wikisearch(term, lang) else - -- TODO: Show the link result = Wikipedia:wikintro(term, lang) end return result @@ -174,7 +185,7 @@ return { "^/[Ww]iki (search) ?(.*)$", "^/[Ww]iki(%w+) (.+)$", "^/[Ww]iki ?(.*)$", - "de.wikipedia.org/wiki/([A-Za-z0-9-_-]+)" + "de.wikipedia.org/wiki/(.+)" }, run = run } \ No newline at end of file