Difference between revisions of "Nick"

From Scriptwiki
Jump to: navigation, search
(fixed some typos)
m (example nickname had incorrect slash)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{stub}}
 
 
Changes your nickname.
 
Changes your nickname.
  
 
  /nick new-nick
 
  /nick new-nick
  
'''Note:'''
+
== Note ==
 
*Valid nickname characters are as follows: 0-9a-z\[]^_`{|}-
 
*Valid nickname characters are as follows: 0-9a-z\[]^_`{|}-
 
*A nickname must also '''not''' begin with a numeric or a hyphen (-).  
 
*A nickname must also '''not''' begin with a numeric or a hyphen (-).  
 
*Some ircd reserve single character nicknames for service bots, QuakeNet '''is''' an example of this.
 
*Some ircd reserve single character nicknames for service bots, QuakeNet '''is''' an example of this.
 
''Here is an example to check if %nick is a valid nickname or not:''
 
''Here is an example to check if %nick is a valid nickname or not:''
  [[var]] %nick = /V/alid
+
  [[var]] %nick = \V\alid
  [[if]] ([[$regex]](%nick,%i,/^([a-z\Q\|[]^_`{}-\E](-\w\Q\|[]^_`{}-\E)*)/i)) {
+
  var %regex = /^([][A-Za-z_\\^`{|}][][\w\\^`{|}-]*)/
 +
[[If-Then-Else|if]] ([[$regex]](%nick,%regex)) {
 
   [[echo]] -ag [[$regml]](1) is a valid nickname!
 
   [[echo]] -ag [[$regml]](1) is a valid nickname!
 
  }
 
  }
Line 17: Line 17:
  
 
If you also want to check that the nickname is atleast two characters long you can replace the * with a + as it will make sure that the second exists:
 
If you also want to check that the nickname is atleast two characters long you can replace the * with a + as it will make sure that the second exists:
  /^([a-z\Q\|[]^_`{}-\E](-\w\Q\|[]^_`{}-\E)+)/i
+
  /^([][A-Za-z_\\^`{|}][][\w\\^`{|}-]+)/
  
  
 
The example below will only match if the whole nickname is valid, so it won't truncate the nickname:
 
The example below will only match if the whole nickname is valid, so it won't truncate the nickname:
  /^([a-z\Q\|[]^_`{}-\E](-\w\Q\|[]^_`{}-\E)*)$/i
+
  /^([][A-Za-z_\\^`{|}][][\w\\^`{|}-]*)$/
 
== See Also ==
 
== See Also ==
{{Relatedraws|nick}}
+
* {{Relatedraws|nick}}
 +
* [[On nick|On nick event]]
  
 
[[Category:Basic IRC commands]]
 
[[Category:Basic IRC commands]]

Latest revision as of 12:56, 20 September 2011

Changes your nickname.

/nick new-nick

Note

  • Valid nickname characters are as follows: 0-9a-z\[]^_`{|}-
  • A nickname must also not begin with a numeric or a hyphen (-).
  • Some ircd reserve single character nicknames for service bots, QuakeNet is an example of this.

Here is an example to check if %nick is a valid nickname or not:

var %nick = \V\alid
var %regex = /^([][A-Za-z_\\^`{|}][][\w\\^`{|}-]*)/
if ($regex(%nick,%regex)) {
  echo -ag $regml(1) is a valid nickname!
}
else { echo -ag %nick is not a valid nickname! }

Note: The above example, if you feed it with \Valid!nvalid, it would return it as a valid nickname, although the only valid part of the nick is \Valid. If you type /nick \Valid!nvalid the ircd would trim the nick to \Valid, this is why in the echo of a valid nickname we use $regml(1) instead of %nick, this is a back reference to the valid nickname captured.

If you also want to check that the nickname is atleast two characters long you can replace the * with a + as it will make sure that the second exists:

/^([][A-Za-z_\\^`{|}][][\w\\^`{|}-]+)/


The example below will only match if the whole nickname is valid, so it won't truncate the nickname:

/^([][A-Za-z_\\^`{|}][][\w\\^`{|}-]*)$/

See Also