Class: IRC::Client::RegisteredState

Inherits:
ConnectedState show all
Defined in:
lib/irc/client/registered_state.rb

Instance Method Summary collapse

Methods inherited from ConnectedState

#disconnect, #on_disconnect, #send_command, #send_command_via_queue

Methods inherited from ConnectionState

#disconnect, #on_ping, #private_message, #send_command, #send_command_via_queue

Methods included from ConnectionListener

#on_connect, #on_disconnect, #on_need_more_parameters, #on_notice, #on_ping, #on_pong, #on_private_message, #on_registration_failure, #on_server_response

Constructor Details

#initializeRegisteredState

Returns a new instance of RegisteredState.



38
39
40
# File 'lib/irc/client/registered_state.rb', line 38

def initialize
  @log = Log4r::Logger.new('IRC::Client::RegisteredState')  
end

Instance Method Details

#connect(context, server) ⇒ Object

Connects to the server.

Raises:



43
44
45
# File 'lib/irc/client/registered_state.rb', line 43

def connect(context, server)
  raise ClientError.new("Can't connect to server. Already connected to a server.")
end

#join(context, channels) ⇒ Object

Joins the given channels.



48
49
50
# File 'lib/irc/client/registered_state.rb', line 48

def join(context, channels)
  IRC::Commands::JoinCommand.new(channels).send(context)
end

#on_join(context, channel, user) ⇒ Object

This method gets called when a user (possibly us) joins a channel.



60
61
62
63
64
# File 'lib/irc/client/registered_state.rb', line 60

def on_join(context, channel, user)
  return unless context.nick.strip.downcase == user.nick.strip.downcase
  context.join_succeeded(channel) 
  @log.debug("#{network_name(context)} Successfully joined channel #{channel}.")
end

#on_join_failure(context, channel, code, reason) ⇒ Object

This message gets called when a channel join attempt failed.



67
68
69
# File 'lib/irc/client/registered_state.rb', line 67

def on_join_failure(context, channel, code, reason)
  @log.debug("#{network_name(context)} Failed to join channel #{channel}. #{reason.capitalize}.")
end

#on_kick(context, channel, kick_user, kicked_user, reason) ⇒ Object

This method gets called when a user gets kicked from a channel.



72
73
# File 'lib/irc/client/registered_state.rb', line 72

def on_kick(context, channel, kick_user, kicked_user, reason)
end

#on_part(context, channel, user) ⇒ Object

This method gets called when a user (possibly us) leaves a channel.



76
77
78
79
80
# File 'lib/irc/client/registered_state.rb', line 76

def on_part(context, channel, user)
  return unless context.nick.strip.downcase == user.nick.strip.downcase
  context.part_succeeded(channel) 
  @log.debug("#{network_name(context)} Successfully left channel #{channel}.")        
end

#on_part_failure(connection, channel) ⇒ Object

This method gets called when a channel part attempt failed.



83
84
# File 'lib/irc/client/registered_state.rb', line 83

def on_part_failure(connection, channel)
end

#part(context, channels) ⇒ Object

Leaves the given channels.



53
54
55
# File 'lib/irc/client/registered_state.rb', line 53

def part(context, channels)
  IRC::Commands::PartCommand.new(channels).send(context)      
end