Skip to content

Commit

Permalink
401がでたらフォールバック
Browse files Browse the repository at this point in the history
  • Loading branch information
cho45 committed May 12, 2010
1 parent a8743e3 commit a60baaf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/tig.rb
Expand Up @@ -238,6 +238,8 @@ class TwitterIrcGateway < Net::IRC::Server::Session
CONSUMER_KEY = 'ZxRg3rGeqE68Tqkz9nhmA'
CONSUMER_SECRET = 'GaJsr2jfjUYIHaPc01UqiqMlvUJPCL5z5uPQM5T418'

class UnauthorizedException < Exception; end

@@ctcp_action_commands = []

class << self
Expand Down Expand Up @@ -343,6 +345,7 @@ def on_user(m)
req.basic_auth(@nick, @pass)
Net::HTTP.start(uri.host, uri.port) do |http|
http.request(req) do |res|
raise UnauthorizedException if res.code.to_i == 401
raise res.code unless res.code.to_i == 200
buf = ""
res.read_body do |str|
Expand Down Expand Up @@ -429,6 +432,8 @@ def on_user(m)
end
end
end
rescue UnauthorizedException => e
@chirp_thread = nil
rescue Exception => e
@log.error e.inspect
e.backtrace.each do |l|
Expand Down

0 comments on commit a60baaf

Please sign in to comment.