Class: IRC::Commands::UserCommand
- Defined in:
- lib/irc/commands/user_command.rb
Overview
Command: USER
Parameters: <username> <hostname> <servername> <realname>
The USER message is used at the beginning of connection to specify the username, hostname, servername and realname of s new user. It is also used in communication between servers to indicate new user arriving on IRC, since only after both USER and NICK have been received from a client does a user become registered.
Between servers USER must to be prefixed with client’s NICKname. Note that hostname and servername are normally ignored by the IRC server when the USER command comes from a directly connected client (for security reasons), but they are used in server to server communication. This means that a NICK must always be sent to a remote server when a new user is being introduced to the rest of the network before the accompanying USER is sent.
It must be noted that realname parameter must be the last parameter, because it may contain space characters and must be prefixed with a colon (‘:’) to make sure this is recognised as such.
Since it is easy for a client to lie about its username by relying solely on the USER message, the use of an “Identity Server” is recommended. If the host which a user connects from has such a server enabled the username is set to that as in the reply from the “Identity Server”.
Numeric Replies:
-
ERR_NEEDMOREPARAMS
-
ERR_ALREADYREGISTRED
Examples:
User registering themselves with a username of “guest” and real name “Ronnie Reagan”.
USER guest tolmoon tolsun :Ronnie Reagan
Message between servers with the nickname for which the USER command belongs to
:testnick USER guest tolmoon tolsun :Ronnie Reagan
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#realname ⇒ Object
readonly
Returns the value of attribute realname.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Attributes inherited from Command
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize(user, host, server, realname) ⇒ UserCommand
constructor
A new instance of UserCommand.
Methods inherited from Command
#execute, #on_server_response, #to_s, #valid_response?, #wait
Methods included from IRC::Client::ConnectionListener
#on_connect, #on_disconnect, #on_error, #on_join, #on_join_failure, #on_kick, #on_nick, #on_nick_already_in_use, #on_notice, #on_part, #on_part_failure, #on_ping, #on_pong, #on_private_message, #on_registration, #on_registration_failure, #on_server_response, #on_welcome
Constructor Details
#initialize(user, host, server, realname) ⇒ UserCommand
Returns a new instance of UserCommand.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/irc/commands/user_command.rb', line 81 def initialize(user, host, server, realname) raise InvalidCommand.new("Can't create user command. User name is missing.") unless user @user = user raise InvalidCommand.new("Can't create user command. Host is missing.") unless host @host = host raise InvalidCommand.new("Can't create user command. Server is missing.") unless server @server = server raise InvalidCommand.new("Can't create user command. Real name is missing.") unless realname @realname = realname super(command) end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
77 78 79 |
# File 'lib/irc/commands/user_command.rb', line 77 def host @host end |
#realname ⇒ Object (readonly)
Returns the value of attribute realname.
79 80 81 |
# File 'lib/irc/commands/user_command.rb', line 79 def realname @realname end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
78 79 80 |
# File 'lib/irc/commands/user_command.rb', line 78 def server @server end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
76 77 78 |
# File 'lib/irc/commands/user_command.rb', line 76 def user @user end |
Instance Method Details
#command ⇒ Object
99 100 101 |
# File 'lib/irc/commands/user_command.rb', line 99 def command return "USER #{user} #{host} #{server} :#{realname}" end |