]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
twitter: bugfix for invalid OAuth PIN Entry
authorNeoLobster <neolobster@snugglenets.com>
Mon, 6 Sep 2010 10:11:49 +0000 (05:11 -0500)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 7 Sep 2010 17:55:47 +0000 (19:55 +0200)
There was a bug in "twitter pin" functionality where it didn't
check to verify that the PIN entered by the user was valid. As
a result, if the user entered an invalid PIN, the bot would
not respond as to whether or not twitter account binding was
successful. I replaced it with an error message if the PIN
is invalid. I also changed the error message for someone
who tries to enter a PIN without first using "twitter
authorize" to be more clear.

data/rbot/plugins/twitter.rb

index df834b0c3178ca55fb6577f8957129361f2064c1..1d86472d940abbeb28b0c57456c94662888a64e8 100644 (file)
@@ -5,7 +5,7 @@
 #
 # Author:: Carter Parks (carterparks) <carter@carterparks.com>
 # Author:: Giuseppe "Oblomov" Bilotta <giuseppe.bilotta@gmail.com>
-# Author:: "NeoLobster" <neolobster@snugglenets.com>
+# Author:: NeoLobster <neolobster@snugglenets.com>
 #
 # Copyright:: (C) 2007 Carter Parks
 # Copyright:: (C) 2007 Giuseppe Bilotta
@@ -170,11 +170,16 @@ class TwitterPlugin < Plugin
 
   def pin(m, params)
      unless @registry.has_key?(m.sourcenick + "_request_token")
-       m.reply "You must first use twitter authorize to get the PIN"
+       m.reply "You must first use twitter authorize to get an authorization URL, which you can use to get a PIN for me to use to verify your Twitter account"
        return false
      end
      @request_token = YAML::load(@registry[m.sourcenick + "_request_token"])
-     @access_token = @request_token.get_access_token( { :oauth_verifier => params[:pin] } )
+     begin
+       @access_token = @request_token.get_access_token( { :oauth_verifier => params[:pin] } )
+     rescue
+       m.reply "Error: There was a problem registering your Twitter account. Please make sure you have the right PIN. If the problem persists, use twitter authorize again to get a new PIN"
+       return false
+     end
      @registry[m.sourcenick + "_access_token"] = YAML::dump(@access_token)
      m.reply "Okay, you're all set"
   end