词条 | Module:IRC Nick |
释义 | local p = {} function p.guessNick( frame ) local username = frame.args[1] local nick -- First, strip out non-ASCII as best we can -- Note this will totally fail for non-Latin-script usernames. Nothing much we can do about that. nick = mw.ustring.toNFD( username ) nick = string.gsub( nick, '[^\\32-\\126]', '' ) -- Next, replace other unacceptable characters if string.match( nick, '^[0-9%-]' ) then -- Begins with a number, so prepend an underscore nick = '_' .. nick end nick = string.gsub( nick, '[^a-zA-Z0-9_%-%[\\%]{|}^`]+', '_' ) -- Cut to 24 charcaters + `|` if username was modified or 25 characters otherwise if nick == username then nick = string.sub( nick, 1, 25 ) else nick = string.sub( nick, 1, 24 ) .. '|' end return nick end return p |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。