Module:ProfileInfoboxUpdater: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(debug log output) |
||
| Line 39: | Line 39: | ||
format = "json" | format = "json" | ||
}) | }) | ||
mw.logObject(data) | |||
local uuid = data.uuid | local uuid = data.uuid | ||
| Line 51: | Line 52: | ||
}) | }) | ||
mw.logObject(userdata) | |||
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 | ||
local groups = userdata.groups | local groups = userdata.groups | ||
mw.logObject(groups) | |||
return groups | return groups | ||
else | else | ||
Revision as of 11:27, 19 July 2024
Documentation for this module may be created at Module:ProfileInfoboxUpdater/doc
--local rank = {}
local 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 api1 = "https://api.ashcon.app/mojang/v2/user/" .. username
local data = externalData.getExternalData({
url = api1,
format = "json"
})
mw.logObject(data)
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 = externalData.getExternalData({
url = "https://statistics.johnymuffin.com/api/v1/getUser?serverID=0&uuid=" .. uuid,
format = "json"
})
mw.logObject(userdata)
if userdata then -- if this doesn't trigger something has gone terribly wrong
local groups = userdata.groups
mw.logObject(groups)
return groups
else
return 'NO GROUPS FOUND'
end
end
end
end
return p