From f1d1734cc6fc94e0fd809c2a1c678dfd35206c01 Mon Sep 17 00:00:00 2001 From: NeoLobster Date: Mon, 6 Sep 2010 05:11:49 -0500 Subject: 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. --- data/rbot/plugins/twitter.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'data') 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) # Author:: Giuseppe "Oblomov" Bilotta -# Author:: "NeoLobster" +# Author:: NeoLobster # # 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 -- cgit v1.2.3