preview.lua: Kürze Beschreibung wenn länger als 300 Zeichen

+fixes
This commit is contained in:
Akamaru 2017-01-30 19:10:33 +01:00
parent 4f3aef6493
commit b53c855788
3 changed files with 7 additions and 1 deletions

View File

@ -11,6 +11,7 @@ function unescape(str)
str = string.gsub(str, '$', '$') -- dollar sign str = string.gsub(str, '$', '$') -- dollar sign
str = string.gsub(str, '%', '%') -- percent sign str = string.gsub(str, '%', '%') -- percent sign
str = string.gsub(str, ''', '\'') -- single quote str = string.gsub(str, ''', '\'') -- single quote
str = string.gsub(str, ''', '\'') -- single quote
str = string.gsub(str, '(', '(') -- opening parenthesis str = string.gsub(str, '(', '(') -- opening parenthesis
str = string.gsub(str, ')', ')') -- closing parenthesis str = string.gsub(str, ')', ')') -- closing parenthesis
str = string.gsub(str, '*', '*') -- asterisk str = string.gsub(str, '*', '*') -- asterisk

View File

@ -49,7 +49,7 @@ function playstation_store:get_info(country_code, game_id)
price = data.default_sku.display_price--..psplus price = data.default_sku.display_price--..psplus
end end
local fsk = data.age_limit local fsk = data.age_limit
local description = string.sub(unescape(data.long_desc:gsub("%b<>", "")), 1, 250)..'...' local description = string.sub(unescape(data.long_desc:gsub("%b<>", "")), 1, 300)..'...'
local release = makeOurDate(data.release_date) local release = 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 = data.images[4].url

View File

@ -29,6 +29,11 @@ function preview:inline_callback(inline_query, config, matches)
if data.description then if data.description then
description = unescape(data.description:gsub('"', '\\"')) description = unescape(data.description:gsub('"', '\\"'))
description_in_text = '\n'..description description_in_text = '\n'..description
if string.len(description_in_text) > 300 then
description_in_text = string.sub(description_in_text, 1, 300)..'...'
else
description_in_text = description_in_text
end
else else
description_in_text = '' description_in_text = ''
description = 'Keine Beschreibung verfügbar' description = 'Keine Beschreibung verfügbar'