Kleinere Fixes in verschiedene Plugins

This commit is contained in:
Akamaru 2016-07-07 21:24:02 +02:00
parent 6e4ff13e59
commit f53481f8de
12 changed files with 37 additions and 17 deletions

2
.gitignore vendored
View File

@ -20,3 +20,5 @@ plugins/figuya.lua
plugins/plex_info.lua plugins/plex_info.lua
plugins/plex_last.lua plugins/plex_last.lua
plugins/akamaru.lua plugins/akamaru.lua
plugins/brawlbot.lua
plugins/strawpoll.lua

View File

@ -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, "♪", "") str = string.gsub(str, "♪", "")
str = string.gsub(str, "<EFBFBD>", "")
-- Ä Ö Ü -- Ä Ö Ü
str = string.gsub(str, "&auml;", "ä") str = string.gsub(str, "&auml;", "ä")

View File

@ -38,9 +38,9 @@ local function switch_afk(user_name, user_id, chat_id, timestamp, text)
if text then if text then
print('Setting redis hash afk_text in '..hash..' to '..text) print('Setting redis hash afk_text in '..hash..' to '..text)
redis:hset(hash, 'afk_text', text) redis:hset(hash, 'afk_text', text)
return user_name..' ist AFK ('..text..')' return user_name..' ist AFK! ('..text..')'
else else
return user_name..' ist AFK' return user_name..' ist AFK!'
end end
end end
@ -90,7 +90,7 @@ end
local function run(msg, matches) local function run(msg, matches)
if msg.to.type ~= "chat" then 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 end
local user_id = msg.from.id local user_id = msg.from.id

View File

@ -1,17 +1,17 @@
do do
local function get_ponywave(part) local function get_aka_img(img)
local url = 'http://img.akamaru.de/'..part..'.html' local url = 'http://img.akamaru.de/'..img..'.html'
local res,code = http.request(url) 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") local url = string.match(res, "id=\"codedirect\" value%=\"(.-)\" onclick")
return url return url
end end
local function run(msg, matches) local function run(msg, matches)
local receiver = get_receiver(msg) local receiver = get_receiver(msg)
local part = matches[1] local img = matches[1]
local url = get_ponywave(part) local url = get_aka_img(img)
if string.ends(url, ".gif") then if string.ends(url, ".gif") then
send_document_from_url(receiver, url) send_document_from_url(receiver, url)
else else
@ -28,4 +28,6 @@ return {
run = run run = run
} }
--by Akamaru [https://ponywave.de]
end end

View File

@ -6,7 +6,7 @@ local makeOurDate = function(dateString)
return day..'.'..month..'.'..year return day..'.'..month..'.'..year
end end
local function get_post(post) local function get_post()
local url = 'http://akamaru.de/?json=get_recent_posts' local url = 'http://akamaru.de/?json=get_recent_posts'
local res,code = http.request(url) local res,code = http.request(url)
local data = json:decode(res).posts[1] local data = json:decode(res).posts[1]
@ -35,7 +35,7 @@ local function get_post(post)
end end
local function run(msg, matches) local function run(msg, matches)
local text, image_url = get_post(post) local text, image_url = get_post()
local receiver = get_receiver(msg) local receiver = get_receiver(msg)
if image_url then if image_url then
local file = download_to_file(image_url) local file = download_to_file(image_url)
@ -45,10 +45,12 @@ local function run(msg, matches)
end end
return { return {
description = "Sendet letzten Aka's Blog Beitrag", description = "Sendet den aktuellen Beitrag von Aka's Blog",
usage = "#aka", usage = "#aka",
patterns = {"^#[Aa][Kk][Aa]$"}, patterns = {"^#[Aa][Kk][Aa]$"},
run = run run = run
} }
--by Akamaru [https://ponywave.de]
end end

View File

@ -52,4 +52,6 @@ return {
run = run run = run
} }
--by Akamaru [https://ponywave.de]
end end

View File

@ -11,6 +11,7 @@ function run(msg, matches)
["test"] = "../Festplatten/Dragoran/Mikubot/sfw/test/", ["test"] = "../Festplatten/Dragoran/Mikubot/sfw/test/",
["anime"] = "../Festplatten/Dragoran/Mikubot/sfw/anime/", ["anime"] = "../Festplatten/Dragoran/Mikubot/sfw/anime/",
["mlp"] = "../Festplatten/Dragoran/Mikubot/sfw/mlp/", ["mlp"] = "../Festplatten/Dragoran/Mikubot/sfw/mlp/",
["doge"] = "../Festplatten/Dragoran/Mikubot/sfw/doge/",
["faktillon"] = "../Festplatten/Dragoran/Mikubot/sfw/faktillon/", ["faktillon"] = "../Festplatten/Dragoran/Mikubot/sfw/faktillon/",
["faktastisch"] = "../Festplatten/Dragoran/Mikubot/sfw/faktastisch/", ["faktastisch"] = "../Festplatten/Dragoran/Mikubot/sfw/faktastisch/",
["gamefakt"] = "../Festplatten/Dragoran/Mikubot/sfw/gamefakt/", ["gamefakt"] = "../Festplatten/Dragoran/Mikubot/sfw/gamefakt/",
@ -31,13 +32,13 @@ function run(msg, matches)
return "Fehler: " .. img return "Fehler: " .. img
end end
else 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
end end
return { return {
description = "Sendet ein zufälliges Bild", 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 (.*)$"}, patterns = {"^#rpic (.*)$"},
run = run run = run
} }

View File

@ -58,6 +58,7 @@ function run(msg, matches)
string.match(msg.text, "nico.ms/sm") or string.match(msg.text, "nico.ms/sm") or
string.match(msg.text, "tumblr.com") or string.match(msg.text, "tumblr.com") or
string.match(msg.text, "kickstarter.com/projects") or string.match(msg.text, "kickstarter.com/projects") or
string.match(msg.text, "pr0gramm.com") or
string.ends(url, ".jpg") or string.ends(url, ".jpg") or
string.ends(url, ".jpeg") or string.ends(url, ".jpeg") or
string.ends(url, ".gif") or string.ends(url, ".gif") or

View File

@ -26,6 +26,12 @@ function send_vimeo_data(data, receiver)
local duration = string.format("%02d:%02d", minutes, seconds) local duration = string.format("%02d:%02d", minutes, seconds)
local text = title..'\n(Hochgeladen von: '..uploader..', '..duration..' Minuten, '..viewCount..' mal angesehen)\n' 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) send_msg(receiver, text, ok_cb, false)
end end

View File

@ -28,7 +28,7 @@ local Wikipedia = {
action = "query", action = "query",
prop = "extracts", prop = "extracts",
format = "json", format = "json",
exchars = 300, exchars = 350,
exsectionformat = "plain", exsectionformat = "plain",
explaintext = "", explaintext = "",
redirects = "" redirects = ""
@ -115,7 +115,7 @@ function Wikipedia:wikintro(text, lang)
local lang = lang or "de" local lang = lang or "de"
local title = page.title local title = page.title
local title_enc = URL.escape(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 else
local text = '"'..text..'" nicht gefunden.' local text = '"'..text..'" nicht gefunden.'
return text return text

View File

@ -129,6 +129,8 @@ function run(msg, matches)
local yt_code = matches[1] local yt_code = matches[1]
local data = get_yt_data(yt_code) local data = get_yt_data(yt_code)
local receiver = get_receiver(msg) 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) send_youtube_data(data, receiver)
end end

View File

@ -16,7 +16,7 @@ function run(msg, matches)
else else
file = 'tmp/'..video file = 'tmp/'..video
end end
send_video(get_receiver(msg), file, ok_cb, false) send_document(get_receiver(msg), file, ok_cb, false)
end end
if string.match(msg.text, "#mp3") then if string.match(msg.text, "#mp3") then
@ -33,6 +33,7 @@ function run(msg, matches)
message = string.gsub(message, ".mp4", "") message = string.gsub(message, ".mp4", "")
message = string.gsub(message, ".mkv", "") message = string.gsub(message, ".mkv", "")
message = string.gsub(message, ".flv", "") message = string.gsub(message, ".flv", "")
message = string.gsub(message, ".webm", "")
return message return message
end end