Nintendo Search & PlayStation Store: Pattern Fix und Code angepasst
This commit is contained in:
parent
df66a4c0a3
commit
06d0042365
@ -1,8 +1,8 @@
|
|||||||
local nintendo_search = {}
|
local nintendo_search = {}
|
||||||
|
|
||||||
nintendo_search.triggers = {
|
nintendo_search.triggers = {
|
||||||
'/nin (.+)',
|
'^/nin (.+)',
|
||||||
'/nintendo (.+)'
|
'^/nintendo (.+)'
|
||||||
}
|
}
|
||||||
|
|
||||||
function nintendo_search:get_info(gametitle)
|
function nintendo_search:get_info(gametitle)
|
||||||
@ -12,7 +12,7 @@ function nintendo_search:get_info(gametitle)
|
|||||||
local data = json.decode(res).response.docs[1]
|
local data = json.decode(res).response.docs[1]
|
||||||
if not data then return 'Nichts gefunden!' end
|
if not data then return 'Nichts gefunden!' end
|
||||||
|
|
||||||
local title = data.title
|
local title = '<b>'..data.title..'</b>'
|
||||||
|
|
||||||
if data.publisher then
|
if data.publisher then
|
||||||
publish = ' von <b>'..data.publisher..'</b>'
|
publish = ' von <b>'..data.publisher..'</b>'
|
||||||
@ -32,17 +32,23 @@ function nintendo_search:get_info(gametitle)
|
|||||||
fsk = '\n<b>'..data.pretty_agerating_s..'</b>'
|
fsk = '\n<b>'..data.pretty_agerating_s..'</b>'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if data.players_to == 1 then
|
||||||
|
player = '\n<b>1 Spieler</b>'
|
||||||
|
else
|
||||||
|
player = '\n<b>1 bis '..data.players_to..' Spieler</b>'
|
||||||
|
end
|
||||||
|
|
||||||
local link = '\n<a href="https://www.nintendo.de'..data.url..'">Webseite besuchen</a>'
|
local link = '\n<a href="https://www.nintendo.de'..data.url..'">Webseite besuchen</a>'
|
||||||
local description = string.sub(unescape(data.excerpt:gsub("%b<>", "")), 1, 300)
|
local description = '\n\n<i>'..string.sub(unescape(data.excerpt:gsub("%b<>", "")), 1, 300)..'</i>'
|
||||||
local release = data.pretty_date_s
|
local release = '\n<b>Release:</b> '..data.pretty_date_s
|
||||||
|
|
||||||
if data.image_url_h2x1_s then
|
if data.image_url_h2x1_s then
|
||||||
image_url = 'http://anditest.perseus.uberspace.de/img.php?url=https:'..data.image_url_h2x1_s
|
image_url = '<a href="http://anditest.perseus.uberspace.de/img.php?url=https:'..data.image_url_h2x1_s..'"> </a>'
|
||||||
else
|
else
|
||||||
image_url = 'http://anditest.perseus.uberspace.de/img.php?url=https:'..data.image_url
|
image_url = '<a href="http://anditest.perseus.uberspace.de/img.php?url=https:'..data.image_url..'"> </a>'
|
||||||
end
|
end
|
||||||
|
|
||||||
local text = '<b>'..title..'</b>'..publish..system..'<a href="'..image_url..'"> </a>'..fsk..'\n'..'<b>Release:</b> '..release..link..'\n\n<i>'..description..'</i>'
|
local text = title..publish..system..image_url..fsk..player..release..link..description
|
||||||
|
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
|
@ -2,6 +2,7 @@ local playstation_store = {}
|
|||||||
|
|
||||||
playstation_store.triggers = {
|
playstation_store.triggers = {
|
||||||
'store.playstation.com/#!/([A-Za-z]+)%-([A-Za-z]+)/.*/cid=(.+)',
|
'store.playstation.com/#!/([A-Za-z]+)%-([A-Za-z]+)/.*/cid=(.+)',
|
||||||
|
'store.playstation.com/([A-Za-z]+)%-([A-Za-z]+)/product/(.+)',
|
||||||
'store.sonyentertainmentnetwork.com/#!/([A-Za-z]+)%-([A-Za-z]+)/.*/cid=(.+)'
|
'store.sonyentertainmentnetwork.com/#!/([A-Za-z]+)%-([A-Za-z]+)/.*/cid=(.+)'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,14 +19,14 @@ function playstation_store:get_info(country_code, game_id)
|
|||||||
local data = json.decode(res)
|
local data = json.decode(res)
|
||||||
if not data then return nil end
|
if not data then return nil end
|
||||||
|
|
||||||
local title = data.name
|
local title = '<b>'..data.name..'</b>'
|
||||||
if data.provider_name then
|
if data.provider_name then
|
||||||
publish = ' von '..data.provider_name
|
publish = ' von <b>'..data.provider_name..'</b>'
|
||||||
else
|
else
|
||||||
publish = ''
|
publish = ''
|
||||||
end
|
end
|
||||||
if data.playable_platform then
|
if data.playable_platform then
|
||||||
system = ' für '..data.playable_platform[1]
|
system = ' für <b>'..data.playable_platform[1]..'</b>'
|
||||||
else
|
else
|
||||||
system = ''
|
system = ''
|
||||||
end
|
end
|
||||||
@ -45,40 +46,36 @@ function playstation_store:get_info(country_code, game_id)
|
|||||||
end
|
end
|
||||||
]]
|
]]
|
||||||
|
|
||||||
price = data.skus[1].rewards[1].display_price..' statt '..data.default_sku.display_price..' (Spare '..data.skus[1].rewards[1].discount..'%)'--..psplus
|
price = '\n<b>Preis:</b> '..data.skus[1].rewards[1].display_price..' statt '..data.default_sku.display_price..' (Spare '..data.skus[1].rewards[1].discount..'%)'--..psplus
|
||||||
else
|
else
|
||||||
price = data.default_sku.display_price--..psplus
|
price = '\n<b>Preis:</b> '..data.default_sku.display_price --..psplus
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
price = 'N/A'
|
price = ''
|
||||||
end
|
end
|
||||||
local fsk = data.age_limit
|
local fsk = '\n<b>Freigegeben ab:</b> '..data.age_limit
|
||||||
local description = string.sub(unescape(data.long_desc:gsub("%b<>", "")), 1, 300)..'...'
|
local description = '\n\n<i>'..string.sub(unescape(data.long_desc:gsub("%b<>", "")), 1, 300)..'...</i>'
|
||||||
local release = makeOurDate(data.release_date)
|
local release = '\n<b>Release:</b> '..makeOurDate(data.release_date)
|
||||||
if data.images[4].type ~= 10 then
|
if data.images[4].type ~= 10 then
|
||||||
image_url = data.images[4].url
|
image_url = '<a href="'..data.images[4].url..'"> </a>'
|
||||||
else
|
else
|
||||||
image_url = data.images[1].url
|
image_url = '<a href="'..data.images[1].url..'"> </a>'
|
||||||
end
|
end
|
||||||
|
|
||||||
local text = '<b>'..title..'</b>'..publish..system..types..'\n<b>Preis:</b> '..price..'\n<b>Freigegeben ab:</b> '..fsk..'\n'..'<b>Release:</b> '..release..'\n\nBeschreibung:\n<i>'..description..'</i>'
|
local text = title..publish..system..types..image_url..price..fsk..release..description
|
||||||
|
|
||||||
return text, image_url
|
return text
|
||||||
end
|
end
|
||||||
|
|
||||||
function playstation_store:action(msg, config, matches)
|
function playstation_store:action(msg, config, matches)
|
||||||
local country_code = string.upper(matches[2])..'/'..matches[1]
|
local country_code = string.upper(matches[2])..'/'..matches[1]
|
||||||
local game_id = matches[3]
|
local game_id = matches[3]
|
||||||
local text, image_url = playstation_store:get_info(country_code, game_id)
|
local text = playstation_store:get_info(country_code, game_id)
|
||||||
if not text then
|
if not text then
|
||||||
utilities.send_reply(msg, chat, config.errors.result)
|
utilities.send_reply(msg, config.errors.results)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if image_url then
|
utilities.send_message(msg.chat.id, text, false, msg.message_id, 'html')
|
||||||
utilities.send_typing(msg.chat.id, 'upload_photo')
|
|
||||||
utilities.send_photo(msg.chat.id, image_url, nil, msg.message_id)
|
|
||||||
end
|
|
||||||
utilities.send_reply(msg, text, 'HTML')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return playstation_store
|
return playstation_store
|
Reference in New Issue
Block a user