2016-07-07 21:36:46 +02:00
|
|
|
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
|
2016-07-07 21:36:46 +02:00
|
|
|
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
|
2016-07-07 21:36:46 +02:00
|
|
|
psplus = ''
|
|
|
|
else
|
|
|
|
psplus = ' PS+ Exklusiv!'
|
2016-07-19 17:23:43 +02:00
|
|
|
end]]
|
2016-07-07 21:36:46 +02:00
|
|
|
|
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
|
2016-07-07 21:36:46 +02:00
|
|
|
else
|
2016-07-19 17:23:43 +02:00
|
|
|
price = data.default_sku.display_price--..psplus
|
2016-07-07 21:36:46 +02:00
|
|
|
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
|
2016-07-07 21:36:46 +02:00
|
|
|
|
|
|
|
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=(.*)"},
|
2016-07-07 21:36:46 +02:00
|
|
|
run = run
|
|
|
|
}
|
|
|
|
|
|
|
|
--by Akamaru [https://ponywave.de]
|
|
|
|
|
|
|
|
end
|