From 7f8f99c8d5ab7f1276d462819c3622b76409db2d Mon Sep 17 00:00:00 2001 From: Akamaru Date: Thu, 7 Jul 2016 21:36:46 +0200 Subject: [PATCH] 3 neue Plugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • PlayStation Store Plugin • Pr0gramm Plugin • Rule34 Plugin (Link) --- plugins/playstation_store.lua | 69 +++++++++++++++++++++++++++++++++++ plugins/pr0gramm.lua | 39 ++++++++++++++++++++ plugins/rule34_link.lua | 35 ++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 plugins/playstation_store.lua create mode 100644 plugins/pr0gramm.lua create mode 100644 plugins/rule34_link.lua diff --git a/plugins/playstation_store.lua b/plugins/playstation_store.lua new file mode 100644 index 0000000..7e4aaaf --- /dev/null +++ b/plugins/playstation_store.lua @@ -0,0 +1,69 @@ +do + +local makeOurDate = function(dateString) + local pattern = "(%d+)%-(%d+)%-(%d+)" + local year, month, day = dateString:match(pattern) + return day..'.'..month..'.'..year +end + +local DESC_LENTH = 400 + +local function get_psn_info(id) + local url = 'https://store.playstation.com/store/api/chihiro/00_09_000/container/DE/de/999/'..id + local res,code = https.request(url) + local data = json:decode(res) + if code ~= 200 then return "HTTP-Fehler" end + if not data then return "Nichts gefunden!" end + + local title = data.title_name + local publish = data.provider_name + local system = data.playable_platform[1] + local type = data.gameContentTypesList[1].name + if data.skus[1].rewards[1] then + + if data.skus[1].rewards[1].isPlus ~= true then + psplus = '' + else + psplus = ' PS+ Exklusiv!' + end + + price = data.skus[1].rewards[1].display_price..' statt '..data.default_sku.display_price..' (Spare '..data.skus[1].rewards[1].discount..'%)'..psplus + else + price = data.default_sku.display_price..psplus + end + local fsk = 'FSK'..data.age_limit + local description = string.sub(unescape(data.long_desc:gsub("%b<>", "")), 1, DESC_LENTH)..'...' + local release = makeOurDate(data.release_date) + if data.images[4].type ~= 10 then + image_url = data.images[4].url + else + image_url = data.images[1].url + end + + local text = title..' von '..publish..' für '..system..' ['..type..']\nPreis: '..price..'\n'..fsk..'\n'..'Release: '..release..'\n\nBeschreibung:\n'..description + + return text, image_url + +end + +local function run(msg, matches) +local id = matches[1] + local text, image_url = get_psn_info(id) + local receiver = get_receiver(msg) + if image_url then + local file = download_to_file(image_url) + send_photo(receiver, file, ok_cb, false) + end + return text +end + +return { + description = "Zeigt PlayStation Store Infos", + usage = "Link zum PlayStation Store", + patterns = {"^https?://store.playstation.com/#!/de%-de/spiel/.*/cid=(.*)$"}, + run = run +} + +--by Akamaru [https://ponywave.de] + +end \ No newline at end of file diff --git a/plugins/pr0gramm.lua b/plugins/pr0gramm.lua new file mode 100644 index 0000000..64afa01 --- /dev/null +++ b/plugins/pr0gramm.lua @@ -0,0 +1,39 @@ +do + +local function get_pr0(ID) + local url = 'http://pr0gramm.com/api/items/get.json?id='..ID + local res,code = http.request(url) + local data = json:decode(res).items[1] + if code ~= 200 then return "HTTP-Fehler" end + if not data then return "HTTP-Fehler" end + + local files = data.image + + return 'http://img.pr0gramm.com/'..files + +end + +local function run(msg, matches) + local ID = matches[1] + local files = get_pr0(ID) + local receiver = get_receiver(msg) + local file = download_to_file(files) + + if string.ends(file, ".gif") or string.ends(file, ".mp4") or string.ends(file, ".webm") then + send_document(receiver, file, ok_cb, false) + else + send_photo(receiver, file, ok_cb, false) + end + +end + +return { + description = "", + usage = "", + patterns = {"pr0gramm.com/.*/(%d+)", "^#[Pp][Rr]0 (%d+)$"}, + run = run +} + +--by Akamaru [https://ponywave.de] + +end \ No newline at end of file diff --git a/plugins/rule34_link.lua b/plugins/rule34_link.lua new file mode 100644 index 0000000..6ab5d3d --- /dev/null +++ b/plugins/rule34_link.lua @@ -0,0 +1,35 @@ +-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 +-- 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 \ No newline at end of file