summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeoLobster <neolobster@snugglenets.com>2010-09-06 05:11:49 -0500
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2010-09-07 19:55:47 +0200
commitf1d1734cc6fc94e0fd809c2a1c678dfd35206c01 (patch)
treee8d55f07027894bccf9967395b9c4c7fdcc52082
parent66ed4d5c2a9a4a018583dc5165e4f3b68d9781ba (diff)
twitter: bugfix for invalid OAuth PIN Entry
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.
-rw-r--r--data/rbot/plugins/twitter.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/data/rbot/plugins/twitter.rb b/data/rbot/plugins/twitter.rb
index df834b0c..1d86472d 100644
--- a/data/rbot/plugins/twitter.rb
+++ b/data/rbot/plugins/twitter.rb
@@ -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