About checking nicknames
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

About checking nicknames

Started by sphynxsoft, 13 November, 2005, 00:50:10

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sphynxsoft

Hi there!
I just melted my brains trying to figure out how to check the users' nicknames. The situaation is I want a nick to look like [Cx]Nickname, where x may be 1, 6, 7, 8 or 17. That's all. Nothing less, nothing more. Can you help? I owe you big!

bastya_elvtars

Are you using the PtokaX way or a script?
Everything could have been anything else and it would have just as much meaning.

sphynxsoft


sphynxsoft

Thanks a lot, Mutor... All my gratitude!

bastya_elvtars

This is my paranoid version.

-- created by bastya_elvtars
--[[			    NICK CHECKING STUFF
				    =====================
				    
BETTER NOT CHANGE THE BADNICK TABLE IF YOU DON'T KNOW WHAT YOU ARE DOING!!!
]]

-- The nick rule redirect address MUST be set in PtokaX.
-- Note that bad characters always get checked in every nick!!!
BadChars = { " ", ";", ",", "+", "<++", "^", "~",}

userlevels={ [-1] = 1, [0] = 5, [1] = 4, [2] = 3, [3] = 2 }

-- Define what prefixes can be used.
-- Can be anything between ( and { and [ and ] and } and ] , these can also be mixed.
-- note that check is case sensitive, so [hun] is not equal to [HUN]
PrefixesNeeded =
  {
    "[HUN]",
    "[EU]",
    "(HUN)",
  }

--[[
Now something new. With these prefixes, one can not enter the hub.
This one works even if prefix check is off.
Obviously these only affect unreg users, and should only contain the most necessary elements.
(Only unregs can have bad prefix, because a user using a bad prefix cannot be registered IMHO. :P)
]]
BadPrefixes=
	  {
	    "[OP]",
	    "[VIP]",
	    "[SU]",
	  }

-- Values: 1 to disconnect, 2 to redirect
BadPrefixToDo=1

Level=3

ExclusionList= -- case of lettters does not matter
{
  "{hublistpinger}","pinger","test-nick"
}

function Main()
  Prefixes={Needed={},Bad={}}
  for k,v in pairs(BadPrefixes) do
    Prefixes.Bad[v]=1
  end
  Prefixes.List="\r\n====================\r\n"
  table.sort(PrefixesNeeded)
  for k,v in pairs(PrefixesNeeded) do
    Prefixes.Needed[v]=1
    Prefixes.List=Prefixes.List..v.."\r\n"
  end
  Prefixes.List=Prefixes.List.."====================\r\n\r\nNote that the check is case sensitive, a.k.a. [prefix] and [PREFIX] are different."
  Immune={}
  for i,v in ipairs(ExclusionList) do
    Immune[string.lower(v)]=1
  end
end

function MyINFOArrival(user,data)
  if Immune[string.lower(user.sName)] then return end
  if not user.bConnected then
    for i,v in ipairs(BadChars) do
	if string.find(user.sName,v,1,true) then
	  local bdchr=v
	  user:SendData("NickNameCheck","Your nick contains the following invalid character (if nothing shows, it's a space): "..v)
	  user:SendData("NickNameCheck","Please correct it and reconnect! Try using only numbers, letters, brackets, underscores and hyphens.")
	  user:SendData("NickNameCheck","Disconnects...")
	  user:Disconnect()
	  return
	end
    end
    local _,_,prefix = string.find(user.sName, "^([%[%{%(]%S+[%)%}%]])%S+")
    if prefix and Prefixes.Bad[prefix] and not user.bRegistered then
	user:SendData("NickNameCheck", prefix.." - This prefix is not allowed for you to use.")
	user:Disconnect()
    end
    if userlevels[user.iProfile] < Level then
	if prefix then
	  if not Prefixes.Needed[prefix] then
	    user:SendData("NickNameCheck", "\r\nBad prefix, use one of these:"..Prefixes.List)
	    if BadPrefixToDo==1 then
		user:Disconnect()
	    else
		user:Redirect(frmHub:GetNickRuleRedirAddr())
	    end
	    return
	  end
	else
	  user:SendData("NickNameCheck", "\r\nNo prefix specified, use one of these:"..Prefixes.List)
	  if BadPrefixToDo==1 then
	    user:Disconnect()
	  else
	    user:Redirect(frmHub:GetNickRuleRedirAddr())
	  end
	end
    end
  end
end
Everything could have been anything else and it would have just as much meaning.

sphynxsoft

LOL! Thank you a lot for the script! I'll try both! Keep up te good job!

SMF spam blocked by CleanTalk