Module:Staff

-- local p = {}

local getArgs = require('Module:Arguments').getArgs local yesno = require('Module:Yesno') local string = require('Module:String') local checkType = require('libraryUtil').checkType

local roles = { ['bureaucrat'] = { class="user-link-bcrat", title="Bureaucrat", plural="Bureaucrats", short="Bcrat", shortPlural="Bcrats", link="Bureaucrats", order=6, };   ['administrator'] = { class="user-link-admin", title="Administrator", plural="Administrators", short="Admin", shortPlural="Admins", link="Admins", order=5, };   ['content moderator'] = { class="user-link-mod", title="Content Moderator", plural="Content Moderators", short="Content Mod", shortPlural="Content Mods", link="Content_Moderators", order=4, };   ['discussions moderator'] = { class="user-link-dmod", title="Discussions Moderator", plural="Discussions Moderator", short="Disc Mod", shortPlural="Disc Mod", link="Disscussions_Moderators", order=3, };   ['rollback'] = { class="user-link-rollback", title="Rollbacker", plural="Rollbackers", short="Rlbckr", shortPlural="Rlbckrs", link="Rollbackers", order=2, };   ['bot'] = { class="user-link-bot", title="Bot", plural="Bots", short="Bot", shortPlural="Bots", link="Bots", order=1, }; }

local aliases = { ['bur']='bureaucrat', ['bcrat']='bureaucrat', ['bureau']='bureaucrat', ['bureaucrat']='bureaucrat', ['crat']='bureaucrat', ['b']='bureaucrat', ['admin']='administrator', ['adm']='administrator', ['ad']='administrator', ['administrator']='administrator', ['administr']='administrator', ['sysop']='administrator', ['content']='content moderator', ['cont']='content moderator', ['cont mod']='content moderator', ['cont moderator']='content moderator', ['content mod']='content moderator', ['content moderator']='content moderator', ['c moderator']='content moderator', ['c mod']='content moderator', ['cm']='content moderator', ['content-moderator']='content moderator', ['d mod']='discussions moderator', ['d moderator']='discussions moderator', ['disc mod']='discussions moderator', ['disc moderator']='discussions moderator', ['discuss m']='discussions moderator', ['discuss mod']='discussions moderator', ['discuss moderator']='discussions moderator', ['disc m']='discussions moderator', ['discussions m']='discussions moderator', ['discussions mod']='discussions moderator', ['discussions moderator']='discussions moderator', ['dm']='discussions moderator', ['thread-moderator']='discussions moderator', ['threadmoderator']='discussions moderator', ['th']='discussions moderator', ['th m']='discussions moderator', ['thr mod']='discussions moderator', ['thread mod']='discussions moderator', ['t mod']='discussions moderator', ['rollback']='rollback', ['roll']='rollback', ['rollb']='rollback', ['rb']='rollback', ['rollbacker']='rollback', ['rback']='rollback', ['b']='bot', ['bot']='bot', ['robot']='bot', ['bt']='bot', }

function p.staffRole(frame) local args = getArgs(frame) local name = args[1] local alt = args[2] local plural = yesno(args["plural"] or args["plur"] or args["p"], false) local shorten = yesno(args["short"] or args["shr"] or args["s"], false) local linkAlt = args["link_alt"] or args["link"] or args["linkalt"] or args["la"] or args["l"] local success, response = pcall(p._staffRole, name, alt, plural, shorten, linkAlt) return success and response or string.error(response) end

function p._staffRole(name, alt, plural, shorten, linkAlt) if type(name) == "table" then alt = name[2] or name.alt or name.alttext or name.altText plural = name[3] or name.plural shorten = name[4] or name.short or name.shorten linkAlt = name[5] or name.linkAlt or name.link name = name[1] or name.name end if name == "" or name == nil then return '' end checkType('_staffRole', 1, name, 'string') checkType('_staffRole', 2, alt, 'string', true) checkType('_staffRole', 3, plural, 'boolean', true) checkType('_staffRole', 4, shorten, 'boolean', true) checkType('_staffRole', 5, linkAlt, 'string', true) if name:lower:match('(\'?s)$') or plural then plural = true name = name:gsub('(\'?s)$', '') else plural = false end local titleId = aliases[name:gsub('_', ' '):lower] local data = roles[titleId]

if not titleId then error(string.format('Invalid staff rank name "%s"', name), 2) end local function hideAlways(s) return ' '..s..' ' end if alt then text = alt else if shorten and plural then text = data.shortPlural elseif shorten then text = data.short elseif plural then text = data.plural else text = data.title end end if linkAlt and linkAlt:match('https?%:%/%/%S*') then output_text = table.concat{ hideAlways(data.order), '[',                   linkAlt, ' ',                    string.wrapHtml(text, ' ', { class=data.class }) ']',               }        elseif linkAlt then output_text = table.concat{ hideAlways(data.order), ,                   string.wrapHtml(text, ' ', { class=data.class }),                    , }       else output_text = table.concat{ hideAlways(data.order), ,                   string.wrapHtml(text, ' ', { class=data.class }),                    , }   end return output_text end

function p.staffMsgBox(frame) local args = getArgs(frame) local rank1 = args[1] or args["rank1"] or args["r1"] or args["rank"] local rank2 = args[2] or args["rank2"] or args["r2"] local msgBox = mw.html.create('div') :addClass('messagebox') :wikitext(table.concat{           'This user is ',            rank1:match('^([aeiouy]+)') and 'an ' or 'a ',            p._staffRole(rank1),            rank2 and ' and '..(rank2:match('^([aeiouy]+)') and 'an ' or 'a ')..p._staffRole(rank2) or ,            ' on the wiki.',            rank2 and ' ' or ,            'The wiki is not affiliated with Hypixel.',            ' ',            string.wrapHtml{                text="This user is not part of the Hypixel staff and has no power in-game.",                tag='span',                attrs={style="color:red;"}            },        }) return tostring(msgBox) end

return p