Commit 88778d78ac1f7ce8273b3ca858d4a32318d8ec30

Parse nick, ident and hostmask
IRCEvent.rb
(13 / 5)
  
1818class IRCEvent
1919 @@handlers = { 'ping' => lambda {|event| IRCConnection.send_to_server("PONG #{event.message}") } }
2020 @@callbacks = Hash.new()
21 attr_reader :hostmask, :message, :event_type, :from, :channel, :target, :mode, :stats
21 attr_reader :hostmask, :message, :event_type, :from, :channel, :target, :mode, :stats, :nick, :ident
2222 def initialize (line)
2323 puts "FROM SERVER: #{line}" if $DEBUG
2424
2828 # mess_parts[1] is the message that was sent
2929 @message = (mess_parts[1] ? mess_parts[1] : "" )
3030 @from = ""
31 @channel = ""
3132
3233 @stats = mess_parts[0].split(" ")
3334
5252 @from = @stats[0]
5353 @user = IRCUser.create_user(@from)
5454 end
55 # FIXME: this list would probably be more accurate to exclude commands than to include them
56 @hostmask = @stats[0] if %W(topic privmsg join).include? @event_type
57 @channel = @stats[2] if @stats[2] && !@channel
55
56 @hostmask = @from.split("@").last
57 @nick = @from.split("!").first
58 @ident = ""
59
60 if @from =~ /!(.+)@/
61 @ident = $1
62 end
63
64 @channel = @stats[2] if @stats[2] and @channel.empty?
5865 @target = @stats[3] if @stats[3]
5966 @mode = @stats[4] if @stats[4]
6067
7171 @channel = @message
7272 end
7373
74 puts "EVENTO: #{@event_type}" if $DEBUG
74 puts "EVENT: #{@event_type}" if $DEBUG
7575
7676 end
7777