Module:ProfileInfoboxUpdater
Documentation for this module may be created at Module:ProfileInfoboxUpdater/doc
--local rank = {} --externalData = mw.ext.externalData --local uuid = {} local p = {} local capiunto = require 'capiunto' --[ Thecow275's Profile Infobox Updater Module V1 ] local function preprocessArg(s) if not s then return nil end s = s:match('^%s*(.-)%s*$') --trim whitespace if s == '' then return nil else return s end end -- HIGHLY EXPERIMENTAL STUFF --local function createHTMLTable(data) -- local html = '<table>' -- for key, value in pairs(data) do -- html = html .. '<tr><td>' .. key .. '</td><td>' .. tostring(value) .. '</td></tr>' -- end -- html = html .. '</table>' -- return html --end -- EXPERIMANTAL STUFF ENDS function p.main(frame) local args = frame.args local username = preprocessArg(args[1]) local datatype = preprocessArg(args[2]) -- currently unused will be used whenever I implement more datatypes if not username then -- check for blank username return 'USERNAME NOT VALID OR API ERROR' end if username == '' then return 'NO USERNAME INPUT' end if username == '{{{username}}}' then return 'TEMPLATE NOTICED' end if username == '{{{1}}}' then return 'thecow275' end if username then local data = mw.ext.externalData.getExternalData({ url = "https://api.ashcon.app/mojang/v2/user/" .. username, format = 'json' }) --local uuid = data.uuid if not data.uuid then --check for blank uuid (if this happens hell has broken lose) return 'NO VALID UUID FOUND' end if data.uuid then --if uuid is valid then get data from johnymuffin jstats api local userdata = mw.ext.externalData.getExternalData({ url = "https://statistics.johnymuffin.com/api/v1/getUser?serverID=0&uuid=" .. data.uuid, data = {deaths='playerDeaths',pkilled='playersKilled',joins='joinCount',traveled='metersTraveled',blocksplaced='blocksPlaced',itemsdropped='itemsDropped',trustlevel='trustLevel',blocksdestroyed='blocksDestroyed',groups = 'Groups', creatureskilled = 'creaturesKilled', balance='money'}, format = 'json' }) if userdata then -- if this doesn't trigger something has gone terribly wrong --local trust = userdata.trustlevel -- Trust Level --local blocksbroken = userdata.blocksdestroyed -- Blocks Broken --local traveled = userdata.traveled -- Meters Traveled --local blocksplaced = userdata.blocksplaced -- Blocks Placed -- local itemsdropped = userdata.itemsdropped -- Items Dropped --local groups = userdata.groups -- Groups as in Ranks local rank = 'nul' local bracketstyle = 'icr-a icr-data' local rankstyle = 'icr-a icr-data' --local balance = string.format("%.2f", userdata.balance) -- local deaths = userdata.deaths -- Player Deaths --local pkilled = userdata.pkilled -- Players Killed --local mkilled = userdata.creatureskilled -- Mob Kills --local balance = userdata.balance -- Player's Money --local joins = userdata.joins -- Join count if userdata.groups then -- RANKLIST START -- if string.find(userdata.groups, "admin") then --ADMIN rank = 'Admin' bracketstyle = 'icr-f icr-data' rankstyle = 'icr-4 icr-data' end if string.find(userdata.groups, "trial") then -- Trial Helper rank = 'Trial Helper' end if string.find(userdata.groups, "moderator") then -- Moderator rank = 'Moderator' end if string.find(userdata.groups, "helper") then -- Helper rank = 'Helper' end if string.find(userdata.groups, "developer") then -- Developer rank = 'Developer' end if string.find(userdata.groups, "diamondcitizen") then -- Diamond Citizen rank = 'Diamond Citizen' end if string.find(userdata.groups, "citizen") then -- Citizen rank = 'Citizen' end if string.find(userdata.groups, "trusted") then -- Gold Citizen rank = 'Gold Citizen' end if string.find(userdata.groups, "hero") then -- Hero rank = 'Hero' end if string.find(userdata.groups, "legend") then -- Legend rank = 'Legend' end if string.find(userdata.groups, "mystic") then -- Mystic rank = 'Mystic' end if string.find(userdata.groups, "donator") then -- Donator rank = 'Donator' end if string.find(userdata.groups, "donatorplus") then -- Donator+ rank = 'Donator+' end if string.find(userdata.groups, "donatorplusplus") then -- Donator++ rank = 'Donator++' end if string.find(userdata.groups, "trooper") then -- Trooper rank = 'Trooper' end if string.find(userdata.groups, "infrastructure") then -- Infrastructure (not used) rank = 'Infrastructure' end -- RANKLIST END -- else rank = 'Wanderer' bracketstyle = 'icr-a icr-data' end local styletop = 'background:#cfc;' if username == 'JohnyMuffin' then styletop = '#5555FF;' else styletop = '#cfc;' end if datatype == 'infobox' then --local idk = trust.."|"..pkilled.."|"..mkilled.."|"..deaths.."|"..traveled.."|"..blocksplaced.."|"..itemsdropped.."|"..blocksbroken --return createHTMLTable(data) local args = frame:getParent().args -- local headerStyle -- headerStyle = 'background-color:red' -- local labelStyle -- labelStyle = 'background-color:#55FF55' -- local dataStyle -- dataStyle = 'background-color:#55FF55; font-weight:bold; display:inline-block; float:right' -- local labelStyle2 -- labelStyle2 = 'style="background-color:#444444"' -- local dataStyle2 -- dataStyle2 = 'style="background-color:#222222; font-weight:bold; display:inline-block; float:left"' local retval = capiunto.create({ --title = username, --titleStyle = --headerStyle = headerStyle, -- labelStyle = labelStyle, --dataStyle = dataStyle, -- labelStyle2 = labelStyle2, --dataStyle2 = dataStyle2, top = username, topStyle = styletop }) --:addImage( args.image, args.caption ) :addImage('https://minotar.net/armor/bust/'..username..'.png','Player Bust','icr-hack') --:addHeader(username, 'icr-title') :addRow('','') --:addWikitext('File:https://minotar.net/armor/bust'..username..'.png') :addRow( 'Username', username, 'icr-6', 'icr-a icr-data' ) :addRow( 'Rank', string.format('<span class="%s">[</span><span class="%s">%s</span><span class="%s">]</span>', bracketstyle,rankstyle,rank,bracketstyle), 'icr-hack-right' ) :addRow( 'UUID', data.uuid, 'icr-data' ) :addRow( 'Balance', string.format("%.2f", userdata.balance),'icr-data') :addHeader( 'Miscellaneous Stats', 'icr-header' ) :addRow( 'Join Count', userdata.joins, 'icr-data' ) :addRow( 'Trust Level', userdata.trustlevel, 'icr-data icr-9', 'icr-8') :addRow( 'Player Kills', userdata.pkilled, 'icr-data icr-f', 'icr-7' ) :addRow( 'Mob Kills', userdata.creatureskilled, 'icr-data' ) :addRow( 'Deaths', userdata.deaths, 'icr-data' ) :addRow( 'Blocks Traveled', userdata.traveled, 'icr-data' ) :addRow( 'Blocks Placed', userdata.blocksplaced, 'icr-data' ) :addRow( 'Items Dropped', userdata.itemsdropped, 'icr-data' ) :addRow( 'Blocks Broken', userdata.blocksdestroyed, 'icr-data') return retval end if datatype == 'rank' then end end end else return 'something went horribly wrong' end end return p