Commit 931f5e2ca25a4aa8dc5f401085fc1e42aa55d227

only call method on_* if object respond to
IRC.rb
(9 / 5)
  
66require 'IRCUser'
77require 'IRCUtil'
88
9
10
119# Class IRC is a master class that handles connection to the irc
1210# server and pasring of IRC events, through the IRCEvent class.
1311class IRC
149149 IRCConnection.send_to_server("WHO #{user}")
150150 end
151151 private
152 def thread_event (event)
153 @threads << Thread.new(event) {|localevent|
154 localevent.process
152 def thread_event(event)
153 @threads << Thread.new(event) { |localevent|
154 begin
155 localevent.process
156 rescue => e
157 puts "Error: #{e.message}"
158 puts e.backtrace.map { |e| " from #{e}\n" }
159 exit -1
160 end
155161 }
156162 end
157163end
IRCBot.rb
(4 / 1)
  
55 def initialize(nick, server, port, realname='RBot')
66 super
77
8 IRCEvent.add_handler("unhandled", lambda { |event| __send__("on_#{event.type}".to_sym, event) } )
8 IRCEvent.add_handler("unhandled", lambda { |event|
9 method_id = "on_#{event.type}".to_sym
10 __send__(method_id, event) if respond_to?(method_id)
11 })
912 end
1013end