From f53481f8dea9401d3eadd2bca69f406f68edb54b Mon Sep 17 00:00:00 2001 From: Akamaru Date: Thu, 7 Jul 2016 21:24:02 +0200 Subject: [PATCH] Kleinere Fixes in verschiedene Plugins --- .gitignore | 4 +++- bot/utils.lua | 1 + plugins/afk.lua | 6 +++--- plugins/akamaru_img.lua | 12 +++++++----- plugins/akasblog.lua | 8 +++++--- plugins/akasblog_search.lua | 2 ++ plugins/random_pic.lua | 5 +++-- plugins/url_title.lua | 1 + plugins/vimeo.lua | 6 ++++++ plugins/wiki.lua | 4 ++-- plugins/youtube.lua | 2 ++ plugins/youtube_dl.lua | 3 ++- 12 files changed, 37 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index af49828..ee5670d 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,6 @@ pictures/3uhrmorgens.jpg plugins/figuya.lua plugins/plex_info.lua plugins/plex_last.lua -plugins/akamaru.lua \ No newline at end of file +plugins/akamaru.lua +plugins/brawlbot.lua +plugins/strawpoll.lua \ No newline at end of file diff --git a/bot/utils.lua b/bot/utils.lua index 5c4e988..71aa84a 100644 --- a/bot/utils.lua +++ b/bot/utils.lua @@ -563,6 +563,7 @@ function unescape(str) str = string.gsub(str, "‹", "‹") str = string.gsub(str, "€", "€") str = string.gsub(str, "♪", "♪") + str = string.gsub(str, "�", "") -- Ä Ö Ü str = string.gsub(str, "ä", "ä") diff --git a/plugins/afk.lua b/plugins/afk.lua index 745dc24..3fee050 100644 --- a/plugins/afk.lua +++ b/plugins/afk.lua @@ -38,9 +38,9 @@ local function switch_afk(user_name, user_id, chat_id, timestamp, text) if text then print('Setting redis hash afk_text in '..hash..' to '..text) redis:hset(hash, 'afk_text', text) - return user_name..' ist AFK ('..text..')' + return user_name..' ist AFK! ('..text..')' else - return user_name..' ist AFK' + return user_name..' ist AFK!' end end @@ -90,7 +90,7 @@ end local function run(msg, matches) if msg.to.type ~= "chat" then - return "Mir ist's egal, ob du AFK bist ._." + return "Mir ist's egal, ob du AFK bist." end local user_id = msg.from.id diff --git a/plugins/akamaru_img.lua b/plugins/akamaru_img.lua index 4b0552b..bb77781 100644 --- a/plugins/akamaru_img.lua +++ b/plugins/akamaru_img.lua @@ -1,17 +1,17 @@ do -local function get_ponywave(part) - local url = 'http://img.akamaru.de/'..part..'.html' +local function get_aka_img(img) + local url = 'http://img.akamaru.de/'..img..'.html' local res,code = http.request(url) - if code ~= 200 then return "Fehler beim Abrufen von img.ponywave.de" end + if code ~= 200 then return "Fehler beim Abrufen von img.akamaru.de" end local url = string.match(res, "id=\"codedirect\" value%=\"(.-)\" onclick") return url end local function run(msg, matches) local receiver = get_receiver(msg) - local part = matches[1] - local url = get_ponywave(part) + local img = matches[1] + local url = get_aka_img(img) if string.ends(url, ".gif") then send_document_from_url(receiver, url) else @@ -28,4 +28,6 @@ return { run = run } +--by Akamaru [https://ponywave.de] + end \ No newline at end of file diff --git a/plugins/akasblog.lua b/plugins/akasblog.lua index f6a09b4..0eecfd8 100644 --- a/plugins/akasblog.lua +++ b/plugins/akasblog.lua @@ -6,7 +6,7 @@ local makeOurDate = function(dateString) return day..'.'..month..'.'..year end -local function get_post(post) +local function get_post() local url = 'http://akamaru.de/?json=get_recent_posts' local res,code = http.request(url) local data = json:decode(res).posts[1] @@ -35,7 +35,7 @@ local function get_post(post) end local function run(msg, matches) - local text, image_url = get_post(post) + local text, image_url = get_post() local receiver = get_receiver(msg) if image_url then local file = download_to_file(image_url) @@ -45,10 +45,12 @@ local function run(msg, matches) end return { - description = "Sendet letzten Aka's Blog Beitrag", + description = "Sendet den aktuellen Beitrag von Aka's Blog", usage = "#aka", patterns = {"^#[Aa][Kk][Aa]$"}, run = run } +--by Akamaru [https://ponywave.de] + end \ No newline at end of file diff --git a/plugins/akasblog_search.lua b/plugins/akasblog_search.lua index a0b0da2..a9ecb12 100644 --- a/plugins/akasblog_search.lua +++ b/plugins/akasblog_search.lua @@ -52,4 +52,6 @@ return { run = run } +--by Akamaru [https://ponywave.de] + end \ No newline at end of file diff --git a/plugins/random_pic.lua b/plugins/random_pic.lua index ed4fa10..ee206ae 100644 --- a/plugins/random_pic.lua +++ b/plugins/random_pic.lua @@ -11,6 +11,7 @@ function run(msg, matches) ["test"] = "../Festplatten/Dragoran/Mikubot/sfw/test/", ["anime"] = "../Festplatten/Dragoran/Mikubot/sfw/anime/", ["mlp"] = "../Festplatten/Dragoran/Mikubot/sfw/mlp/", + ["doge"] = "../Festplatten/Dragoran/Mikubot/sfw/doge/", ["faktillon"] = "../Festplatten/Dragoran/Mikubot/sfw/faktillon/", ["faktastisch"] = "../Festplatten/Dragoran/Mikubot/sfw/faktastisch/", ["gamefakt"] = "../Festplatten/Dragoran/Mikubot/sfw/gamefakt/", @@ -31,13 +32,13 @@ function run(msg, matches) return "Fehler: " .. img end else - return '"'..imgtype..'" gibt es nicht.\nEs gibt:\nanime\nmlp\nfaktillon\nfaktastisch\ngamefakt\nfaktglaublich' + return '"'..imgtype..'" gibt es nicht.\nEs gibt:\nanime\nmlp\ndoge\nfaktillon\nfaktastisch\ngamefakt\nfaktglaublich' end end return { description = "Sendet ein zufälliges Bild", - usage = {"#rpic [Thema]","Themen:","anime","mlp","faktillon","faktastisch","gamefakt","faktglaublich"}, + usage = {"#rpic [Thema]","Themen:","anime","mlp","doge","faktillon","faktastisch","gamefakt","faktglaublich"}, patterns = {"^#rpic (.*)$"}, run = run } diff --git a/plugins/url_title.lua b/plugins/url_title.lua index 19718be..3143436 100644 --- a/plugins/url_title.lua +++ b/plugins/url_title.lua @@ -58,6 +58,7 @@ function run(msg, matches) string.match(msg.text, "nico.ms/sm") or string.match(msg.text, "tumblr.com") or string.match(msg.text, "kickstarter.com/projects") or + string.match(msg.text, "pr0gramm.com") or string.ends(url, ".jpg") or string.ends(url, ".jpeg") or string.ends(url, ".gif") or diff --git a/plugins/vimeo.lua b/plugins/vimeo.lua index 77c401f..cc353e8 100644 --- a/plugins/vimeo.lua +++ b/plugins/vimeo.lua @@ -26,6 +26,12 @@ function send_vimeo_data(data, receiver) local duration = string.format("%02d:%02d", minutes, seconds) local text = title..'\n(Hochgeladen von: '..uploader..', '..duration..' Minuten, '..viewCount..' mal angesehen)\n' + local image = download_to_file(data[1].thumbnail_large) + if string.ends(image, ".webp") then + send_document(receiver, image, ok_cb, false) + else + send_photo(receiver, image, ok_cb, false) + end send_msg(receiver, text, ok_cb, false) end diff --git a/plugins/wiki.lua b/plugins/wiki.lua index 11074c4..fd398dd 100644 --- a/plugins/wiki.lua +++ b/plugins/wiki.lua @@ -28,7 +28,7 @@ local Wikipedia = { action = "query", prop = "extracts", format = "json", - exchars = 300, + exchars = 350, exsectionformat = "plain", explaintext = "", redirects = "" @@ -115,7 +115,7 @@ function Wikipedia:wikintro(text, lang) local lang = lang or "de" local title = page.title local title_enc = URL.escape(title) - return title..":\n"..page.extract.."\n -- https://"..lang..".wikipedia.org/wiki/"..title_enc + return title.."\n"..unescape(page.extract).."\n -- https://"..lang..".wikipedia.org/wiki/"..title_enc else local text = '"'..text..'" nicht gefunden.' return text diff --git a/plugins/youtube.lua b/plugins/youtube.lua index d5c8474..2f39344 100644 --- a/plugins/youtube.lua +++ b/plugins/youtube.lua @@ -129,6 +129,8 @@ function run(msg, matches) local yt_code = matches[1] local data = get_yt_data(yt_code) local receiver = get_receiver(msg) + local thumb = download_to_file('http://i.ytimg.com/vi_webp/'..yt_code..'/hqdefault.webp') + send_document(receiver, thumb, ok_cb, false) send_youtube_data(data, receiver) end diff --git a/plugins/youtube_dl.lua b/plugins/youtube_dl.lua index b0c5731..4a03d50 100644 --- a/plugins/youtube_dl.lua +++ b/plugins/youtube_dl.lua @@ -16,7 +16,7 @@ function run(msg, matches) else file = 'tmp/'..video end - send_video(get_receiver(msg), file, ok_cb, false) + send_document(get_receiver(msg), file, ok_cb, false) end if string.match(msg.text, "#mp3") then @@ -33,6 +33,7 @@ function run(msg, matches) message = string.gsub(message, ".mp4", "") message = string.gsub(message, ".mkv", "") message = string.gsub(message, ".flv", "") + message = string.gsub(message, ".webm", "") return message end