35 lines
1.1 KiB
Lua
35 lines
1.1 KiB
Lua
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
|
|
-- DO NOT USE WITHOUT PERMISSION
|
|
-- Edited by Akamaru [https://PonyWave.de]
|
|
|
|
do
|
|
|
|
local function get_r34_post(id)
|
|
local url = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%27http%3A%2F%2Frule34.xxx%2Findex.php%3Fpage%3Ddapi%26s%3Dpost%26q%3Dindex%26id%3D'..id..'%27&format=json'
|
|
local res,code = https.request(url)
|
|
local r34 = json:decode(res).query.results.posts.post
|
|
if code ~= 200 then return "HTTP-Fehler" end
|
|
local img_url = r34.file_url
|
|
return img_url
|
|
end
|
|
|
|
local function run(msg, matches)
|
|
local id = matches[1]
|
|
local receiver = get_receiver(msg)
|
|
local img_url = get_r34_post(id)
|
|
local file = download_to_file(img_url)
|
|
if string.ends(file, ".gif") then
|
|
send_document(receiver, file, ok_cb, false)
|
|
else
|
|
send_photo(receiver, file, ok_cb, false)
|
|
end
|
|
end
|
|
|
|
return {
|
|
description = "Sendet ein Bild von rule34.xxx",
|
|
usage = "rule34.xxx Link",
|
|
patterns = {"https?://rule34.xxx/index.php%?page=post&s=view&id=(%d+)"},
|
|
run = run
|
|
}
|
|
|
|
end |