Nintendo Search & PlayStation Store: Pattern Fix und Code angepasst

This commit is contained in:
Akamaru 2017-11-09 14:45:15 +01:00
parent df66a4c0a3
commit 06d0042365
2 changed files with 31 additions and 28 deletions

View File

@ -1,8 +1,8 @@
local nintendo_search = {}
nintendo_search.triggers = {
'/nin (.+)',
'/nintendo (.+)'
'^/nin (.+)',
'^/nintendo (.+)'
}
function nintendo_search:get_info(gametitle)
@ -12,7 +12,7 @@ function nintendo_search:get_info(gametitle)
local data = json.decode(res).response.docs[1]
if not data then return 'Nichts gefunden!' end
local title = data.title
local title = '<b>'..data.title..'</b>'
if data.publisher then
publish = ' von <b>'..data.publisher..'</b>'
@ -32,17 +32,23 @@ function nintendo_search:get_info(gametitle)
fsk = '\n<b>'..data.pretty_agerating_s..'</b>'
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 description = string.sub(unescape(data.excerpt:gsub("%b<>", "")), 1, 300)
local release = data.pretty_date_s
local description = '\n\n<i>'..string.sub(unescape(data.excerpt:gsub("%b<>", "")), 1, 300)..'</i>'
local release = '\n<b>Release:</b> '..data.pretty_date_s
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
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
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
end

View File

@ -2,6 +2,7 @@ local playstation_store = {}
playstation_store.triggers = {
'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=(.+)'
}
@ -18,14 +19,14 @@ function playstation_store:get_info(country_code, game_id)
local data = json.decode(res)
if not data then return nil end
local title = data.name
local title = '<b>'..data.name..'</b>'
if data.provider_name then
publish = ' von '..data.provider_name
publish = ' von <b>'..data.provider_name..'</b>'
else
publish = ''
end
if data.playable_platform then
system = ' für '..data.playable_platform[1]
system = ' für <b>'..data.playable_platform[1]..'</b>'
else
system = ''
end
@ -45,40 +46,36 @@ function playstation_store:get_info(country_code, game_id)
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
price = data.default_sku.display_price--..psplus
price = '\n<b>Preis:</b> '..data.default_sku.display_price --..psplus
end
else
price = 'N/A'
price = ''
end
local fsk = data.age_limit
local description = string.sub(unescape(data.long_desc:gsub("%b<>", "")), 1, 300)..'...'
local release = makeOurDate(data.release_date)
local fsk = '\n<b>Freigegeben ab:</b> '..data.age_limit
local description = '\n\n<i>'..string.sub(unescape(data.long_desc:gsub("%b<>", "")), 1, 300)..'...</i>'
local release = '\n<b>Release:</b> '..makeOurDate(data.release_date)
if data.images[4].type ~= 10 then
image_url = data.images[4].url
image_url = '<a href="'..data.images[4].url..'"> </a>'
else
image_url = data.images[1].url
image_url = '<a href="'..data.images[1].url..'"> </a>'
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
function playstation_store:action(msg, config, matches)
local country_code = string.upper(matches[2])..'/'..matches[1]
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
utilities.send_reply(msg, chat, config.errors.result)
utilities.send_reply(msg, config.errors.results)
return
end
if image_url then
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')
utilities.send_message(msg.chat.id, text, false, msg.message_id, 'html')
end
return playstation_store