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/playstation_store.lua

73 lines
2.0 KiB
Lua
Raw Normal View History

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
2016-07-19 17:23:43 +02:00
if data.provider_name then
publish = ' von '..data.provider_name
else
publish = ''
end
local system = data.playable_platform[1]
local type = data.gameContentTypesList[1].name
if data.skus[1].rewards[1] then
2016-07-19 17:23:43 +02:00
--[[if data.skus[1].rewards[1].isPlus ~= true then
psplus = ''
else
psplus = ' PS+ Exklusiv!'
2016-07-19 17:23:43 +02:00
end]]
2016-07-19 17:23:43 +02:00
price = data.skus[1].rewards[1].display_price..' statt '..data.default_sku.display_price..' (Spare '..data.skus[1].rewards[1].discount..'%)'--..psplus
else
2016-07-19 17:23:43 +02:00
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
2016-07-19 17:23:43 +02:00
local text = title..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",
2016-07-20 16:58:57 +02:00
patterns = {"store.playstation.com/#!/de%-de/.*/cid=(.*)"},
run = run
}
--by Akamaru [https://ponywave.de]
end