Commit 88778d78ac1f7ce8273b3ca858d4a32318d8ec30
- Diff rendering mode:
- inline
- side by side
IRCEvent.rb
(13 / 5)
|   | |||
| 18 | 18 | class IRCEvent | |
| 19 | 19 | @@handlers = { 'ping' => lambda {|event| IRCConnection.send_to_server("PONG #{event.message}") } } | |
| 20 | 20 | @@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 | ||
| 22 | 22 | def initialize (line) | |
| 23 | 23 | puts "FROM SERVER: #{line}" if $DEBUG | |
| 24 | 24 | ||
| … | … | ||
| 28 | 28 | # mess_parts[1] is the message that was sent | |
| 29 | 29 | @message = (mess_parts[1] ? mess_parts[1] : "" ) | |
| 30 | 30 | @from = "" | |
| 31 | @channel = "" | ||
| 31 | 32 | ||
| 32 | 33 | @stats = mess_parts[0].split(" ") | |
| 33 | 34 | ||
| … | … | ||
| 52 | 52 | @from = @stats[0] | |
| 53 | 53 | @user = IRCUser.create_user(@from) | |
| 54 | 54 | 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? | ||
| 58 | 65 | @target = @stats[3] if @stats[3] | |
| 59 | 66 | @mode = @stats[4] if @stats[4] | |
| 60 | 67 | ||
| … | … | ||
| 71 | 71 | @channel = @message | |
| 72 | 72 | end | |
| 73 | 73 | ||
| 74 | puts "EVENTO: #{@event_type}" if $DEBUG | ||
| 74 | puts "EVENT: #{@event_type}" if $DEBUG | ||
| 75 | 75 | ||
| 76 | 76 | end | |
| 77 | 77 |

