Class: IRC::Messages::NickMessage

Inherits:
Message
  • Object
show all
Defined in:
lib/irc/messages/nick_message.rb

Overview

4.1.2 Nick message

Command: NICK Parameters: <nickname> [ <hopcount> ]

NICK message is used to give user a nickname or change the previous one. The <hopcount> parameter is only used by servers to indicate how far away a nick is from its home server. A local connection has a hopcount of 0. If supplied by a client, it must be ignored.

If a NICK message arrives at a server which already knows about an identical nickname for another client, a nickname collision occurs. As a result of a nickname collision, all instances of the nickname are removed from the server’s database, and a KILL command is issued to remove the nickname from all other server’s database. If the NICK message causing the collision was a nickname change, then the original (old) nick must be removed as well.

If the server recieves an identical NICK from a client which is directly connected, it may issue an ERR_NICKCOLLISION to the local client, drop the NICK command, and not generate any kills.

Numeric Replies:

ERR_NONICKNAMEGIVEN ERR_ERRONEUSNICKNAME ERR_NICKNAMEINUSE ERR_NICKCOLLISION

Example:

NICK Wiz ; Introducing new nick “Wiz”.

:WiZ NICK Kilroy ; WiZ changed his nickname to Kilroy.

Constant Summary collapse

CODE =
"NICK"

Constants inherited from Message

Message::MESSAGE_FORMAT

Constants included from Codes

Codes::ERR_ALREADYREGISTRED, Codes::ERR_BADCHANMASK, Codes::ERR_BADCHANNAME, Codes::ERR_BADCHANNELKEY, Codes::ERR_BANNEDFROMCHAN, Codes::ERR_CANNOTSENDTOCHAN, Codes::ERR_CANTKILLSERVER, Codes::ERR_CHANNELISFULL, Codes::ERR_CHANOPRIVSNEEDED, Codes::ERR_ERRONEUSNICKNAME, Codes::ERR_FILEERROR, Codes::ERR_INVALIDUSERNAME, Codes::ERR_INVITEONLYCHAN, Codes::ERR_KEYSET, Codes::ERR_LINKCHANNEL, Codes::ERR_NEEDMOREPARAMS, Codes::ERR_NICKCOLLISION, Codes::ERR_NICKNAMEINUSE, Codes::ERR_NOADMININFO, Codes::ERR_NOLOGIN, Codes::ERR_NOMOTD, Codes::ERR_NONICKNAMEGIVEN, Codes::ERR_NOOPERHOST, Codes::ERR_NOORIGIN, Codes::ERR_NOPERMFORHOST, Codes::ERR_NOPRIVILEGES, Codes::ERR_NORECIPIENT, Codes::ERR_NOSERVICEHOST, Codes::ERR_NOSUCHCHANNEL, Codes::ERR_NOSUCHNICK, Codes::ERR_NOSUCHSERVER, Codes::ERR_NOTEXTTOSEND, Codes::ERR_NOTONCHANNEL, Codes::ERR_NOTOPLEVEL, Codes::ERR_NOTREGISTERED, Codes::ERR_PASSWDMISMATCH, Codes::ERR_SECUREONLYCHAN, Codes::ERR_SUMMONDISABLED, Codes::ERR_TARGETTOOFAST, Codes::ERR_TOOMANYCHANNELS, Codes::ERR_TOOMANYTARGETS, Codes::ERR_UMODEUNKNOWNFLAG, Codes::ERR_UNKNOWNCOMMAND, Codes::ERR_UNKNOWNMODE, Codes::ERR_USERNOTINCHANNEL, Codes::ERR_USERONCHANNEL, Codes::ERR_USERSDISABLED, Codes::ERR_USERSDONTMATCH, Codes::ERR_WASNOSUCHNICK, Codes::ERR_WILDTOPLEVEL, Codes::ERR_YOUREBANNEDCREEP, Codes::ERR_YOUWILLBEBANNED, Codes::RPL_ADMINEMAIL, Codes::RPL_ADMINLOC1, Codes::RPL_ADMINLOC2, Codes::RPL_ADMINME, Codes::RPL_AWAY, Codes::RPL_BANLIST, Codes::RPL_BOUNCE, Codes::RPL_CHANNELMODEIS, Codes::RPL_CLOSEEND, Codes::RPL_CLOSING, Codes::RPL_CREATED, Codes::RPL_ENDOFBANLIST, Codes::RPL_ENDOFINFO, Codes::RPL_ENDOFLINKS, Codes::RPL_ENDOFMOTD, Codes::RPL_ENDOFNAMES, Codes::RPL_ENDOFSERVICES, Codes::RPL_ENDOFSTATS, Codes::RPL_ENDOFUSERS, Codes::RPL_ENDOFWHO, Codes::RPL_ENDOFWHOIS, Codes::RPL_ENDOFWHOWAS, Codes::RPL_INFO, Codes::RPL_INFOSTART, Codes::RPL_INVITING, Codes::RPL_ISON, Codes::RPL_ISUPPORT, Codes::RPL_KILLDONE, Codes::RPL_LINKS, Codes::RPL_LIST, Codes::RPL_LISTEND, Codes::RPL_LISTSTART, Codes::RPL_LUSERCHANNELS, Codes::RPL_LUSERCLIENT, Codes::RPL_LUSERME, Codes::RPL_LUSEROP, Codes::RPL_LUSERUNKNOWN, Codes::RPL_MOTD, Codes::RPL_MOTDSTART, Codes::RPL_MYINFO, Codes::RPL_MYPORTIS, Codes::RPL_NAMREPLY, Codes::RPL_NONE, Codes::RPL_NOTOPIC, Codes::RPL_NOUSERS, Codes::RPL_NOWAWAY, Codes::RPL_REHASHING, Codes::RPL_SERVICE, Codes::RPL_SERVICEINFO, Codes::RPL_SERVLIST, Codes::RPL_SERVLISTEND, Codes::RPL_STATSCLINE, Codes::RPL_STATSCOMMANDS, Codes::RPL_STATSHLINE, Codes::RPL_STATSILINE, Codes::RPL_STATSKLINE, Codes::RPL_STATSLINKINFO, Codes::RPL_STATSLLINE, Codes::RPL_STATSNLINE, Codes::RPL_STATSOLINE, Codes::RPL_STATSQLINE, Codes::RPL_STATSUPTIME, Codes::RPL_STATSYLINE, Codes::RPL_SUMMONING, Codes::RPL_TIME, Codes::RPL_TOPIC, Codes::RPL_TOPICINFO, Codes::RPL_TRACECLASS, Codes::RPL_TRACECONNECTING, Codes::RPL_TRACEHANDSHAKE, Codes::RPL_TRACELINK, Codes::RPL_TRACELOG, Codes::RPL_TRACENEWTYPE, Codes::RPL_TRACEOPERATOR, Codes::RPL_TRACESERVER, Codes::RPL_TRACEUNKNOWN, Codes::RPL_TRACEUSER, Codes::RPL_UMODEIS, Codes::RPL_UNAWAY, Codes::RPL_USERHOST, Codes::RPL_USERS, Codes::RPL_USERSSTART, Codes::RPL_VERSION, Codes::RPL_WELCOME, Codes::RPL_WHOISCHANNELS, Codes::RPL_WHOISCHANOP, Codes::RPL_WHOISIDLE, Codes::RPL_WHOISOPERATOR, Codes::RPL_WHOISSERVER, Codes::RPL_WHOISUSER, Codes::RPL_WHOREPLY, Codes::RPL_WHOWASUSER, Codes::RPL_YOUREOPER, Codes::RPL_YOURHOST

Instance Attribute Summary collapse

Attributes inherited from Message

#code, #host, #login, #message, #nick, #raw_message, #server

Instance Method Summary collapse

Methods inherited from Message

#==, #eql?, #initialize, is_valid?, #to_s

Constructor Details

This class inherits a constructor from IRC::Messages::Message

Instance Attribute Details

#afterObject (readonly)

Returns the value of attribute after.



71
72
73
# File 'lib/irc/messages/nick_message.rb', line 71

def after
  @after
end

#beforeObject (readonly)

Returns the value of attribute before.



72
73
74
# File 'lib/irc/messages/nick_message.rb', line 72

def before
  @before
end

Instance Method Details

#handle(context) ⇒ Object

Notify all connection listeners, that a user changed it’s nick name.



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/irc/messages/nick_message.rb', line 75

def handle(context)
  
  # Notify all connection listeners by calling their on_server_response method.
  super(context)
  
  # Notify all connection listeners by calling their on_nick method.
  notify(context) do |connection_listener| 
    connection_listener.on_nick(context, context.lookup_user(before), context.lookup_user(after))
  end

end