Steam Plugin ausgebessert
This commit is contained in:
parent
4683274d21
commit
f0db1fe156
@ -5,17 +5,6 @@ do
|
||||
local BASE_URL = 'http://store.steampowered.com/api/appdetails/'
|
||||
local DESC_LENTH = 400
|
||||
|
||||
local function unescape(str)
|
||||
str = string.gsub( str, '<', '<' )
|
||||
str = string.gsub( str, '>', '>' )
|
||||
str = string.gsub( str, '"', '"' )
|
||||
str = string.gsub( str, ''', "'" )
|
||||
str = string.gsub( str, '&#(%d+);', function(n) return string.char(n) end )
|
||||
str = string.gsub( str, '&#x(%d+);', function(n) return string.char(tonumber(n,16)) end )
|
||||
str = string.gsub( str, '&', '&' ) -- Be sure to do this after all others
|
||||
return str
|
||||
end
|
||||
|
||||
local function get_steam_data (appid)
|
||||
local url = BASE_URL
|
||||
url = url..'?appids='..appid
|
||||
@ -28,7 +17,7 @@ end
|
||||
|
||||
|
||||
local function price_info (data)
|
||||
local price = '' -- If no data is empty
|
||||
local price = '(Kostenlos)' -- If data is empty
|
||||
|
||||
if data then
|
||||
local initial = data.initial
|
||||
@ -36,9 +25,10 @@ local function price_info (data)
|
||||
local min = math.min(data.initial, data.final)
|
||||
price = tostring(min/100)
|
||||
if data.discount_percent and initial ~= final then
|
||||
price = price..data.currency..' ('..data.discount_percent..'% OFF)'
|
||||
end
|
||||
price = price..' €'
|
||||
price = '('..price..'€ '..data.discount_percent..'% OFF)'
|
||||
else
|
||||
price = '('..price..'€)'
|
||||
end
|
||||
end
|
||||
|
||||
return price
|
||||
@ -50,7 +40,7 @@ local function send_steam_data(data, receiver)
|
||||
local title = data.name
|
||||
local price = price_info(data.price_overview)
|
||||
|
||||
local text = title..'\nPreis: '..price..'\n'..description
|
||||
local text = title..' '..price..'\n'..description
|
||||
local image_url = data.header_image
|
||||
local cb_extra = {
|
||||
receiver = receiver,
|
||||
@ -68,9 +58,12 @@ local function run(msg, matches)
|
||||
end
|
||||
|
||||
return {
|
||||
description = "Steam-Info",
|
||||
usage = {"store.steampowered.com/app Link","steamcommunity.com/app Link"},
|
||||
patterns = {"store.steampowered.com/app/([0-9]+)","steamcommunity.com/app/([0-9]+)"},
|
||||
description = "Postet Info zu Steam-Spiel",
|
||||
usage = "Link zu Steam-Spiel",
|
||||
patterns = {
|
||||
"store.steampowered.com/app/([0-9]+)",
|
||||
"steamcommunity.com/app/([0-9]+)"
|
||||
},
|
||||
run = run
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user