summaryrefslogtreecommitdiff
path: root/lib/rbot/ircbot.rb
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-06-28 16:02:24 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-06-28 16:02:24 +0000
commitd764894efae89970e22bad48db4c76d878b35630 (patch)
tree8ad362f53df602b856d2d4132b56e05dc0afdade /lib/rbot/ircbot.rb
parent1676abaf61c9b6c40714e00d6637e3a73d8b527b (diff)
Fix issue #101
Diffstat (limited to 'lib/rbot/ircbot.rb')
-rw-r--r--lib/rbot/ircbot.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index b2c7a88f..51457a56 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -334,7 +334,7 @@ class IrcBot
connect
@timer.start
- while true
+ while @socket.connected?
if @socket.select
break unless reply = @socket.gets
@client.process reply
@@ -346,8 +346,10 @@ class IrcBot
#rescue TimeoutError, SocketError => e
rescue SystemExit
exit 0
+ rescue TimeoutError => e
+ puts e
rescue Exception => e
- puts "network exception: connection closed: #{e.inspect}"
+ puts "network exception: #{e.inspect}"
puts e.backtrace.join("\n")
@socket.shutdown # now we reconnect
rescue => e
@@ -613,10 +615,10 @@ class IrcBot
debug "no PONG from server for #{diff} seconds, reconnecting"
begin
@socket.shutdown
- # TODO
- # raise an exception to get back to the mainloop
rescue
debug "couldn't shutdown connection (already shutdown?)"
+ ensure
+ raise TimeoutError, "no PONG from server in #{diff} seconds"
end
@last_ping = nil
end