This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot/plugins/akamaru_img.lua

33 lines
817 B
Lua
Raw Normal View History

2015-12-06 17:20:12 +01:00
do
2016-07-07 21:24:02 +02:00
local function get_aka_img(img)
local url = 'http://img.akamaru.de/'..img..'.html'
2015-12-06 17:20:12 +01:00
local res,code = http.request(url)
2016-07-07 21:24:02 +02:00
if code ~= 200 then return "Fehler beim Abrufen von img.akamaru.de" end
2015-12-06 17:20:12 +01:00
local url = string.match(res, "id=\"codedirect\" value%=\"(.-)\" onclick")
return url
end
local function run(msg, matches)
local receiver = get_receiver(msg)
2016-07-07 21:24:02 +02:00
local img = matches[1]
local url = get_aka_img(img)
2015-12-06 17:20:12 +01:00
if string.ends(url, ".gif") then
send_document_from_url(receiver, url)
else
send_photo_from_url(receiver, url)
end
end
return {
description = "Mirrored Bild bei Link auf Preview-Seite von img.akamaru.de",
usage = "Preview-Link von img.akamaru.de",
patterns = {
"https?://img.akamaru.de/(.*).html"
},
run = run
}
2016-07-07 21:24:02 +02:00
--by Akamaru [https://ponywave.de]
2015-12-06 17:20:12 +01:00
end