lib/potato/irc/events.rb in potato-0.0.12 vs lib/potato/irc/events.rb in potato-0.0.13

- old
+ new

@@ -70,29 +70,19 @@ # @param [IRC::Packet] pkt # @return [void] def on_pass pkt notice "Attempting to retrieve authtoken." - begin - tok = Timeout::timeout(30) { - Potato::DAmn::Token.get(@config.nick, pkt.args[0]) - } - rescue Timeout::Error - notice "dAmn server is down. Try again later." - @client.quit - @socket.close - return - end + tok = Potato::DAmn::Token.get(@config.nick, pkt.args[0]) if tok.nil? notice "Unable to retrieve an authtoken (server didn't respond)." - @client.quit - @socket.close + close return elsif tok.empty? notice "Wrong password or username. (no authtoken retrieved)" else - notice "You have successfully logged in." + notice "Authtoken retrieved successfully." @logged_in = true @config.token = tok @client.connect_with(@config.nick, @config.token) unless Server.opts.rooms.empty? Server.opts.rooms.each do |room| @@ -128,11 +118,10 @@ end # @param [IRC::Packet] pkt # @return [void] def on_quit pkt - @client.quit - @socket.close + close end end end end \ No newline at end of file