Fixes & Verbesserungen

-download_to_file in paar Plugins entfernt
-Antworte auf Nachrichten
-Stabilitätsverbesserungen
This commit is contained in:
Akamaru 2016-12-15 19:24:08 +01:00
parent 90eb1add06
commit cddb7e03ab
13 changed files with 58 additions and 112 deletions

View File

@ -22,7 +22,7 @@ function about:init(config)
end
function about:action(msg, config)
utilities.send_message(msg.chat.id, about.text, true, nil, true)
utilities.send_message(msg.chat.id, about.text, true, msg.message_id, true)
end
return about

View File

@ -11,30 +11,27 @@ function figuya:get_figuya(figu)
if c ~= 200 then return nil end
local data = json.decode(b)
local title = '*'..data.title..'*'
local desc = '\n'..unescape(data.description)
local pic = data.thumbnail_url
local text = title..desc
if string.len(text) > 200 then
text = string.sub(unescape(text:gsub("%b<>", "")), 1, 197)..'...'
local title = data.title
if string.len(data.description) > 400 then
desc = string.sub(unescape(data.description:gsub("%b<>", "")), 1, 400)..'..'
else
text = text
desc = unescape(data.description)..'.'
end
local pic = data.thumbnail_url
local text = '<b>'..title..'</b>\n<i>'..desc..'</i>'..'<a href="'..pic..'">.</a>'
return text, pic
return text
end
function figuya:action(msg, config, matches)
local figu = matches[1]
local text, pic = figuya:get_figuya(figu)
local text = figuya:get_figuya(figu)
if not text then
utilities.send_reply(msg, config.errors.results)
return
end
utilities.send_typing(receiver, 'upload_photo')
utilities.send_photo(msg.chat.id, pic, text)
utilities.send_message(msg.chat.id, text, false, msg.message_id, 'html')
end
return figuya

View File

@ -72,8 +72,7 @@ function playstation_store:action(msg, config, matches)
end
if image_url then
utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(image_url)
utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
utilities.send_photo(msg.chat.id, image_url, nil, msg.message_id)
end
utilities.send_reply(msg, text, 'HTML')
end

View File

@ -159,12 +159,7 @@ function plex:get_plex(query)
text = title..from..studio..date1..episodes..fsk..duration..rating..desc
end
if string.match(title, 'Local Network') then
return 'Nichts gefunden!'
else
return text, pic, data.title
end
end
function plex:inline_callback(inline_query, config, matches)
@ -196,7 +191,7 @@ function plex:action(msg, config)
if pic then
utilities.send_typing(receiver, 'upload_photo')
local file = download_to_file(pic, 'plex.png')
utilities.send_photo(msg.chat.id, file)
utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end
utilities.send_reply(msg, text, 'HTML')
end

View File

@ -9,15 +9,6 @@ function pokedex:init(config)
]]
end
function pokedex:get_sprite(path)
local url = "http://pokeapi.co/"..path
local b, c = http.request(url)
if c ~= 200 then return nil end
local data = json.decode(b)
local image = data.image
return image
end
function pokedex:get_pkmn(query)
local url = "http://pokeapi.co/api/v1/pokemon/" .. query .. "/"
local res, code = http.request(url)
@ -39,21 +30,22 @@ function pokedex:get_pkmn(query)
end
function pokedex:action(msg, config)
local input = utilities.input_from_msg(msg)
if not input then
local query = utilities.input_from_msg(msg)
if not query then
utilities.send_reply(msg, pokedex.doc, true)
return
end
utilities.send_typing(msg.chat.id, 'typing')
local text, id = pokedex:get_pkmn(input)
local text, id = pokedex:get_pkmn(query)
local image = 'http://pokeapi.co/media/img/'..id..'.png'
if not text then
utilities.send_reply(msg, config.errors.result)
return
end
utilities.send_typing(msg.chat.id, 'upload_photo')
utilities.send_photo(msg.chat.id, download_to_file('http://pokeapi.co/media/img/'..id..'.png'), nil, msg.message_id)
utilities.send_photo(msg.chat.id, image, nil, msg.message_id)
utilities.send_reply(msg, text, 'HTML')
end

View File

@ -20,37 +20,39 @@ function ponyfaces:get_ponyface_by_id(id)
if code ~= 200 then return nil end
local data = json.decode(res)
if not data then return nil end
return data.faces[1].image
local link = 'http://ponyfac.es/'..data.faces[1].id
local pic = data.faces[1].image
return link, pic
end
function ponyfaces:get_ponyface(tag)
local url = BASE_URL..'/tag:'..tag
local res, code = http.request(url)
if code ~= 200 then return nil end
local pf = json.decode(res).faces
local data = json.decode(res).faces
-- truly randomize
math.randomseed(os.time())
-- random max json table size
local i = math.random(#pf)
local link_image = pf[i].image
return link_image
local i = math.random(#data)
local link = 'http://ponyfac.es/'..data[i].id
local pic = data[i].image
return link, pic
end
function ponyfaces:action(msg, config, matches)
if tonumber(matches[1]) ~= nil then
local id = matches[1]
url = ponyfaces:get_ponyface_by_id(id)
link, pic = ponyfaces:get_ponyface_by_id(id)
else
local tag = matches[1]
url = ponyfaces:get_ponyface(tag)
link, pic = ponyfaces:get_ponyface(tag)
end
if not url then
if not pic then
utilities.send_reply(msg, config.errors.results)
return
end
utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(url, 'pf.png')
utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
utilities.send_photo(msg.chat.id, pic, link, msg.message_id)
end
return ponyfaces

View File

@ -1,32 +0,0 @@
local pornhub = {}
function pornhub:init(config)
pornhub.triggers = {
"pornhub.com/gif/(.+)$",
"^/phg (.+)$",
"^/porngif (.+)$"
}
pornhub.doc = [[*
]]..config.cmd_pat..[[phg* _<ID>_: Sendet GIF von PornHub (NSFW)]]
end
pornhub.command = 'ge <ID>'
function pornhub:action(msg, config, matches)
local url = 'http://img.pornhub.com/gif/'..matches[1]..'.gif'
utilities.send_typing(msg.chat.id, 'upload_document')
local file = download_to_file(url)
if not file then
utilities.send_reply(msg, config.errors.results)
return
end
if string.starts(msg.text_lower, '/phg') or string.starts(msg.text_lower, '/porngif') then
source = 'http://www.pornhub.com/gif/'..matches[1]
else
source = nil
end
utilities.send_document(msg.chat.id, file, source, msg.message_id)
end
return pornhub

View File

@ -31,12 +31,11 @@ function pr0gramm:action(msg, config, matches)
return
end
utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(url)
utilities.send_typing(msg.chat.id, 'upload_document')
if string.match(url, ".gif") or string.match(url, ".zip") or string.match(url, ".webm") or string.match(url, ".mp4") then
utilities.send_document(msg.chat.id, file, nil, msg.message_id)
utilities.send_document(msg.chat.id, url, nil, msg.message_id)
else
utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
utilities.send_photo(msg.chat.id, url, nil, msg.message_id)
end
end

View File

@ -103,7 +103,7 @@ function quotes:action(msg, config, matches)
end
if matches[1] == "quote" then
utilities.send_message(msg.chat.id, quotes:get_quote(msg), true, nil, false)
utilities.send_message(msg.chat.id, quotes:get_quote(msg), true, msg.message_id, false)
return
elseif matches[1] == "addquote" and matches[2] then
utilities.send_reply(msg, quotes:save_quote(msg), true)

View File

@ -25,9 +25,9 @@ function rule34:get_r34_info(tag)
local i = math.random(#r34)
local url = 'http:'..r34[i].file_url
local img_url = 'http:'..r34[i].file_url
local source_url = 'http://rule34.xxx/index.php?page=post&s=view&id='..r34[i].id
return url, source_url
return img_url, source_url
end
function rule34:get_r34_post(id)
@ -51,32 +51,29 @@ function rule34:action(msg, config, matches)
utilities.send_reply(msg, 'Nobody here but us chickens!')
return
end
utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(img_url)
if string.ends(img_url, ".gif") then
utilities.send_document(msg.chat.id, file, nil, msg.message_id)
utilities.send_typing(msg.chat.id, 'upload_document')
utilities.send_document(msg.chat.id, img_url, nil, msg.message_id)
else
utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
utilities.send_typing(msg.chat.id, 'upload_photo')
utilities.send_photo(msg.chat.id, img_url, nil, msg.message_id)
end
else
local tag = string.gsub(matches[1], " ", '_')
local tag = string.gsub(tag, ":", '%%3A')
local tag = string.gsub(tag, "+", '%%2B')
local url, id = rule34:get_r34_info(tag)
if not url then
local img_url, source_url = rule34:get_r34_info(tag)
if not img_url then
utilities.send_reply(msg, 'Nobody here but us chickens!')
return
end
utilities.send_typing(msg.chat.id, 'upload_photo')
local file = download_to_file(url)
if string.ends(url, ".gif") then
utilities.send_document(msg.chat.id, file, id, msg.message_id)
if string.ends(img_url, ".gif") then
utilities.send_typing(msg.chat.id, 'upload_document')
utilities.send_document(msg.chat.id, img_url, source_url, msg.message_id)
else
utilities.send_photo(msg.chat.id, file, id, msg.message_id)
utilities.send_typing(msg.chat.id, 'upload_photo')
utilities.send_photo(msg.chat.id, img_url, source_url, msg.message_id)
end
end
end

View File

@ -17,20 +17,19 @@ end
soundboard.command = 'sound <Sound>'
local BASE_URL = 'http://code.ponywave.de/workspace/mikubot/sounds'
--local BASE_URL = 'http://kyouko.local/sounds'
local GRONKH_URL = 'http://code.ponywave.de/workspace/mikubot/gronkhsounds'
function soundboard:inline_callback(inline_query, config, matches)
local board = matches[1]
local input = matches[2]
if board == 'sound' then
url = BASE_URL..'/'..string.lower(input)..'.mp3'
sound = BASE_URL..'/'..string.lower(input)..'.mp3'
elseif board == 'gronkh' then
url = GRONKH_URL..'/'..string.lower(input)..'.mp3'
sound = GRONKH_URL..'/'..string.lower(input)..'.mp3'
end
local _, code = get_http_header(url)
local _, code = get_http_header(sound)
if code ~= 200 then utilities.answer_inline_query(inline_query, nil, 5, true) return end
local results = '[{"type":"audio","id":"7900","title":"'..input..'","audio_url":"'..url..'"}]'
local results = '[{"type":"audio","id":"7900","title":"'..input..'","audio_url":"'..sound..'"}]'
utilities.answer_inline_query(inline_query, results, 2)
end
@ -49,17 +48,16 @@ function soundboard:action(msg, config, matches)
end
if board == 'sound' then
url = BASE_URL..'/'..string.lower(input)..'.mp3'
sound = BASE_URL..'/'..string.lower(input)..'.mp3'
elseif board == 'gronkh' then
url = GRONKH_URL..'/'..string.lower(input)..'.mp3'
sound = GRONKH_URL..'/'..string.lower(input)..'.mp3'
end
local sound = download_to_file(url)
if not sound then
utilities.send_reply(msg, config.errors.results)
return
end
utilities.send_audio(msg.chat.id, sound, msg.message_id)
utilities.send_audio(msg.chat.id, sound, nil, msg.message_id)
end
return soundboard

View File

@ -25,7 +25,7 @@ special.triggers = {
"^[Nn][Aa][Nn][Oo] [Hh][Aa][Kk][Aa][Ss][Ee]$",
"^/[Tt][Hh][Yy][Mm][Ee]$",
"^[Yy][Oo][Ll][Oo]$",
"[Ii] [Ww][Ii][Ss][Hh] [Ss][Qq][Uu][Ii][Dd][Ss] [Ww][Ee][Rr][Ee] [Rr][Ee][Aa][Ll]",
"^[Ii] [Ww][Ii][Ss][Hh] [Ss][Qq][Uu][Ii][Dd][Ss] [Ww][Ee][Rr][Ee] [Rr][Ee][Aa][Ll]$",
"^/[Kk][Ii][Ll][Ll] (.*)",
"^[Pp][Ee]$",
"^[Vv][Aa]$",

View File

@ -29,8 +29,7 @@ function spotify:send_track_data(data, msg)
local text = '<b>'..name..'</b> von <b>'..artist..'</b> aus dem Album <b>'..album..'</b> <i>('..duration..')</i>'
if preview then
utilities.send_typing(msg.chat.id, 'upload_audio')
local file = download_to_file(preview, name..'.mp3')
utilities.send_audio(msg.chat.id, file, 'Aus dem Album "'..album..'"\nLänge: '..duration, msg.message_id, 30, artist, name)
utilities.send_audio(msg.chat.id, preview, 'Aus dem Album "'..album..'"\nLänge: '..duration, msg.message_id, 30, artist, name)
else
utilities.send_reply(msg, text, 'HTML')
end