From d51ee9bf1d31b06dd64295738ca79d4237f5aebc Mon Sep 17 00:00:00 2001 From: Akamaru Date: Thu, 26 Nov 2015 15:18:47 +0100 Subject: [PATCH] Neu Openings.moe Plugin Ignoriere openings.moe in media.lua und url_title.lua --- plugins/media.lua | 5 ++++- plugins/openings_moe.lua | 32 ++++++++++++++++++++++++++++++++ plugins/url_title.lua | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 plugins/openings_moe.lua diff --git a/plugins/media.lua b/plugins/media.lua index 1a73649..8fa4a36 100644 --- a/plugins/media.lua +++ b/plugins/media.lua @@ -10,7 +10,10 @@ local function run(msg, matches) local mime_type = mimetype.get_content_type_no_sub(ext) - if ext == 'gif' then + if string.match(url, "openings.moe/%?video") then + print('Ungültig, da "'..url..'"') + + elseif ext == 'gif' then print('Sende Datei') send_document(receiver, file, rmtmp_cb, cb_extra) diff --git a/plugins/openings_moe.lua b/plugins/openings_moe.lua new file mode 100644 index 0000000..0ca97d8 --- /dev/null +++ b/plugins/openings_moe.lua @@ -0,0 +1,32 @@ +do + +local function get_opening(opening) + local url = 'http://openings.moe/api/details.php?file='..opening..'.webm' + local res,code = http.request(url) + local data = json:decode(res) + if code ~= 200 then return "HTTP-Fehler" end + if not data then return "HTTP-Fehler" end + + local number = data.title + local title = data.source + local url = 'http://openings.moe/video/'..data.filename + + local text = number..' von '..title..'\n'..url + return text +end + +local function run(msg, matches) + local receiver = get_receiver(msg) + local opening = matches[1] + local text = get_opening(opening) + return text +end + +return { + description = "Sendet Infos zu einem Opening", + usage = "Openings.moe Link", + patterns = {"openings.moe/%?video=(.*).webm$"}, + run = run +} + +end \ No newline at end of file diff --git a/plugins/url_title.lua b/plugins/url_title.lua index 612f055..1cf591b 100644 --- a/plugins/url_title.lua +++ b/plugins/url_title.lua @@ -92,6 +92,7 @@ function run(msg, matches) string.match(msg.text, "urbandictionary.com/define.php")or string.match(msg.text, "wikia.com") or string.match(msg.text, "rule34.xxx/index.php") or + string.match(msg.text, "openings.moe/%?video") or string.match(msg.text, "dropbox.com/s/") then print('Ungültig, da "'..title..'"') else