Module:PlayerInfobox

local categorization = require("Module:Categorization") local utils = require("Module:Utils") local i18n = require('Dev:I18n').loadMessages('Module:PlayerInfobox/i18n') local infobox_utils = require('Module:InfoboxUtils') local yesno = require('Dev:Yesno') local staffData = require('Module:RobloxStaff') local names = require('Module:Names')

local categorize = categorization.categorize_in_namespaces('Community')

local p = {}

function p._format_activity(args) local activity = args.activity:lower if activity == "permanently banned" or activity == "deleted" then activity = "terminated" end return i18n:msg("activity-" .. activity) .. categorize(i18n:msg("cat-activity-" .. activity)) end

p.format_activity = utils.make_wrapper_function(p._format_activity)

function p._format_month_joined(args) local lang = mw.getContentLanguage local year = tonumber(lang:formatDate("Y", args["month joined"])) if year < 2004 then return error(i18n:msg("error-early-year", year)) end return lang:formatDate("F Y", args["month joined"]) .. categorize(i18n:msg("cat-year-users", year)) end

p.format_month_joined = utils.make_wrapper_function(p._format_month_joined)

function p._format_staff(args) local t = staffData.getRole(args.name or mw.title.getCurrentTitle.text) if not t then return "" end if args.name == "Shedletsky" then return " Former administrator" .. categorize("Former administrators") end local rString = "" for i,job in pairs(t) do	   if job == "Admin" then rString = rString.. " Administrator" .. categorize("Administrators") elseif job == "Former_Admin" then rString = rString.. " Former administrator" .. categorize("Former administrators") elseif job == "Intern" then rString = rString.. " Intern" .. categorize("Interns") elseif job == "Former_Intern" then rString = rString.. " Former intern" .. categorize("Former interns") elseif job == "Accelerator" then rString = rString.. " Accelerator" .. categorize("Accelerators") elseif job == "Incubator" then rString = rString.. " Incubator" .. categorize("Incubators") elseif job == "Former_Accelerator" then rString = rString.. " Former accelerator" .. categorize("Former accelerators") elseif job == "Former_Incubator" then rString = rString.. " Former incubator" .. categorize("Former incubators") elseif job == "Community_Champion" then rString = rString.." Former Community Champion" .. categorize("Community Champions") elseif job == "Top_Contributor" then rString = rString .. " Former Top Contributor" .. categorize("Top Contributors") elseif job == "Community_Sage" then rString = rString .. " Former Community Sage" .. categorize("Community Sages") elseif job == "Video_Star" then rString = rString .. " Video Star" .. categorize("Video Stars") elseif job == "Former_Video_Star" then rString = rString .. " Former Video Star" .. categorize("Former Video Stars") elseif job == "Former_Moderator" then rString = rString.." Former Moderator" .. categorize("Former moderators") elseif job == "QA_Tester" then rString = rString.." QA Tester" .. categorize("QA testers") elseif job == "UGC_Creator" then rString = rString.." UGC Creator" .. categorize("UGC Creators") elseif job == "Event_Organizer" then rString = rString.." Event Organizer" .. categorize("Event Organizers") elseif job:sub(1,7) == "Custom:" then local data = mw.text.split(job,":",true) rString = rString .. (data[3] and " " or "") .. data[2] end rString = rString .. " "   end return rString end p.format_staff = utils.make_wrapper_function(p._format_staff)

function p._format_rname(args) if names[(args.name or mw.title.getCurrentTitle.text):lower] then return names[(args.name or mw.title.getCurrentTitle.text):lower] end end

p.format_rname = utils.make_wrapper_function(p._format_rname)

function p._format_staff_position_label(args) local t = staffData.getRole(args.name or mw.title.getCurrentTitle.text) if not t then return "Position" end for i,job in pairs(t) do       if job == "Admin" then return "Position" elseif job == "Former_Admin" then return "Former position" end end end

p.format_staff_position_label = utils.make_wrapper_function(p._format_staff_position_label)

function p._format_staff_position(args) local t = staffData.getStaffPosition(args.name or mw.title.getCurrentTitle.text) if not t then return "" end local rString = "" if #t == 1 then rString = t[1] else for i,v in pairs(t) do			rString = rString.."*"..v.."\n" end end if t[1] == "Shared staff account" then rString = rString .. categorize("Shared staff accounts") end return rString end

p.format_staff_position = utils.make_wrapper_function(p._format_staff_position)

function p._format_membership(args) local membership = args.membership:lower if membership == 'premium' or membership == 'p' then return ' Premium' .. categorize("Premium players") elseif membership == "none" then return "None" else return infobox_utils.error_message(" must be “premium” or “none”") end end

p.format_membership = utils.make_wrapper_function(p._format_membership)

function p._format_visits(args) local visits = args.visits or args["place visits"] if not visits then return end if visits == "0" and p._format_staff(args) == nil then return 'None FLAG::SUSPECTED_NCU '..categorize("Players with less than 1000000 place visits") else return "Around "..infobox_utils.format_number(visits, 10000,"Players with less than 1000000 place visits", 1000000, "SUSPECTED_NCU") end end

p.format_visits = utils.make_wrapper_function(p._format_visits)

local social_media_list = { {"twitter","External Twitter.png","https://twitter.com/%s"}, {"youtube","External YouTube.png","https://www.youtube.com/%s"}, {"tiktok","External TikTok.png","https://www.tiktok.com/@%s"}, {"facebook","External Facebook.png","https://www.facebook.com/%s"}, {"instagram","External Instagram.png","https://instagram.com/%s"}, {"twitch","External Twitch.png","https://www.twitch.tv/%s"}, {"guilded","External Guilded.png","https://www.guilded.gg/%s"}, {"deviantart","External DA.png","https://www.deviantart.com/%s"}, {"artstation","External ArtStation.png","https://www.artstation.com/%s"}, {"rwiki" or "rwikia","External RWikia.png","https://roblox.fandom.com/wiki/User:%s"}, }

function p._format_social_media(args) local retString = "" for i,v in pairs(social_media_list) do       if args[v[1]] then retString = retString .. " "       end end if retString ~= "" then retString = retString .. categorize("Pages with social links") end return retString end

p.format_social_media = utils.make_wrapper_function(p._format_social_media,true)

return p