Module:ProfileInfoboxUpdater: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
--local rank = {} | --local rank = {} | ||
externalData = mw.ext.externalData | |||
--local uuid = {} | --local uuid = {} | ||
local p = {} | local p = {} | ||
Line 34: | Line 34: | ||
if username then | if username then | ||
local data = externalData.getExternalData({ | local data = mw.ext.externalData.getExternalData({ | ||
url = "https://api.ashcon.app/mojang/v2/user/" .. username, | url = "https://api.ashcon.app/mojang/v2/user/" .. username, | ||
format = 'json' | format = 'json' | ||
Line 47: | Line 47: | ||
if uuid then | if uuid then | ||
local userdata = externalData.getExternalData({ | local userdata = mw.ext.externalData.getExternalData({ | ||
url = "https://statistics.johnymuffin.com/api/v1/getUser?serverID=0&uuid=" .. data.uuid, | url = "https://statistics.johnymuffin.com/api/v1/getUser?serverID=0&uuid=" .. data.uuid, | ||
data = {groups = 'Groups'}, | |||
format = 'json' | format = 'json' | ||
}) | |||
if userdata then -- if this doesn't trigger something has gone terribly wrong | if userdata then -- if this doesn't trigger something has gone terribly wrong | ||
Line 83: | Line 83: | ||
end | end | ||
end | end | ||
return p | return p |
Revision as of 11:28, 28 August 2024
Documentation for this module may be created at Module:ProfileInfoboxUpdater/doc
--local rank = {} externalData = mw.ext.externalData --local uuid = {} local p = {} --[ 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 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 local data = mw.ext.externalData.getExternalData({ url = "https://api.ashcon.app/mojang/v2/user/" .. username, format = 'json' }) local uuid = data.uuid if not uuid then --check for blank uuid (if this happens hell has broken lose) return 'NO VALID UUID FOUND' end if uuid then local userdata = mw.ext.externalData.getExternalData({ url = "https://statistics.johnymuffin.com/api/v1/getUser?serverID=0&uuid=" .. data.uuid, data = {groups = 'Groups'}, format = 'json' }) if userdata then -- if this doesn't trigger something has gone terribly wrong local groups = userdata.groups if groups then if string.find(groups, "admin") then return 'Admin' end if string.find(groups, "trial") then return 'Trial Helper' end else return 'NO GROUPS FOUND' end end end end end return p