2015-12-07 19:44:52 +01:00
do
local makeOurDate = function ( dateString )
local pattern = " (%d+)%-(%d+)%-(%d+) "
local year , month , day = dateString : match ( pattern )
2015-12-12 23:27:30 +01:00
if day == " 00 " then
return month .. ' . ' .. year
else
2015-12-07 19:44:52 +01:00
return day .. ' . ' .. month .. ' . ' .. year
2015-12-12 23:27:30 +01:00
end
2015-12-07 19:44:52 +01:00
end
local function get_info ( name )
local url = ' http://myfigurecollection.net/api.php?type=json&mode=collection&username= ' .. name
local res , code = http.request ( url )
local data = json : decode ( res ) . collection.owned
if code ~= 200 then return " HTTP-Fehler " end
if not data then return " HTTP-Fehler " end
local title = data.item [ 1 ] . data.name
local owned = data.num_items
local user = ' http://de.myfigurecollection.net/collection/ ' .. name
local art = data.item [ 1 ] . root.name
local category = data.item [ 1 ] . category.name
local date = makeOurDate ( data.item [ 1 ] . data.release_date )
local price = ' ¥ ' .. data.item [ 1 ] . data.price
local url = ' http://de.myfigurecollection.net/item/ ' .. data.item [ 1 ] . data.id
local text = ' Letzter Artikel von ' .. name .. " 's Sammlung ( " .. owned .. ' Artikel) \n ' .. user .. ' \n \n ' .. title .. ' \n Art: ' .. art .. ' ( ' .. category .. ' ) \n Erschien am ' .. date .. ' für ' .. price .. ' \n ' .. url
return text
end
local function run ( msg , matches )
local name = matches [ 1 ]
local text = get_info ( name )
local receiver = get_receiver ( msg )
return text
end
return {
description = " Zeigt den zuletzt hinzugefügten Artikel eines MyFigureCollection Users " ,
2016-06-22 13:59:06 +02:00
usage = " #mfc [Name] " ,
patterns = { " ^#[Mm][Ff][Cc] (.*)$ " ,
2015-12-07 19:44:52 +01:00
" myfigurecollection.net/user/(.*)$ " ,
" myfigurecollection.net/collection/(.*)$ "
} ,
run = run
}
end