Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function NickTag:CheckName (name)
- --> as nicktag only work internally in the guild, we think that is not necessary a work filter to avoid people using bad language.
- -- if (type (name) ~= "string") then
- -- return false, LibStub ("AceLocale-3.0"):GetLocale ("NickTag-1.0")["STRING_ERROR_4"] --> error 4 = name isn't a valid string
- -- end
- -- name = trim (name)
- -- --> limit nickname to 12 characters, same as wow.
- -- local len = string.len (name)
- -- if (len > 99) then
- -- return false, LibStub ("AceLocale-3.0"):GetLocale ("NickTag-1.0")["STRING_ERROR_1"] --> error 1 = nickname is too long, max of 12 characters.
- -- end
- -- --> check if contain any non allowed characters, by now only accpet letters, numbers and spaces.
- -- --> by default wow do not accetp spaces, but here will allow.
- -- --> tested over lua 5.2 and this capture was okey with accents, not sure why inside wow this doesn't work.
- -- local notallow = string.find (name, "[^a-zA-Z�������%s]")
- -- if (notallow) then
- -- return false, LibStub ("AceLocale-3.0"):GetLocale ("NickTag-1.0")["STRING_ERROR_2"] --> error 2 = nickname only support letters, numbers and spaces.
- -- end
- -- --> check if there is sequencial repeated characters, like "Jasooon" were repeats 3 times the "o" character.
- -- --> got this from http://stackoverflow.com/questions/15608299/lua-pattern-matching-repeating-character
- -- have_repeated = false
- -- count_spaces = 0
- -- string.gsub (name, '.', '\0%0%0'):gsub ('(.)%z%1','%1'):gsub ('%z.([^%z]+)', check_repeated)
- -- if (count_spaces > 10) then
- -- have_repeated = true
- -- end
- -- if (have_repeated) then
- -- return false, LibStub ("AceLocale-3.0"):GetLocale ("NickTag-1.0")["STRING_ERROR_3"] --> error 3 = cant use the same letter three times consecutively, 2 spaces consecutively or 3 or more spaces.
- -- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement