summaryrefslogtreecommitdiff
path: root/data/rbot
diff options
context:
space:
mode:
Diffstat (limited to 'data/rbot')
-rw-r--r--data/rbot/plugins/twitter.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/data/rbot/plugins/twitter.rb b/data/rbot/plugins/twitter.rb
index 045b6172..1c8f61dd 100644
--- a/data/rbot/plugins/twitter.rb
+++ b/data/rbot/plugins/twitter.rb
@@ -58,6 +58,10 @@ class TwitterPlugin < Plugin
m.reply [failed_action, "I cannot authenticate to Twitter (OAuth not available)"].join(' because ')
end
+ def report_key_missing(m, failed_action)
+ m.reply [failed_action, "no Twitter Consumer Key/Secret is defined"].join(' because ')
+ end
+
def help(plugin, topic="")
return "twitter status [nick] => show nick's (or your) status, use 'twitter friends status [nick]' to also show the friends' timeline | twitter update [status] => updates your status on twitter | twitter authorize => Generates an authorization URL which will give you a PIN to authorize the bot to use your twitter account. | twitter pin [pin] => Finishes bot authorization using the PIN provided by the URL from twitter authorize. | twitter deauthorize => Makes the bot forget your Twitter account. | twitter actions [on|off] => enable/disable twitting of actions (/me does ...)"
end
@@ -167,8 +171,9 @@ class TwitterPlugin < Plugin
end
def authorize(m, params)
+ failed_action = "we can't complete the authorization process"
unless @has_oauth
- report_oauth_missing(m, "we can't complete the authorization process")
+ report_oauth_missing(m, failed_action)
return false
end
@@ -182,6 +187,11 @@ class TwitterPlugin < Plugin
key = @bot.config['twitter.key']
secret = @bot.config['twitter.secret']
+ if key.empty? or secret.empty?
+ report_key_missing(m, failed_action)
+ return false
+ end
+
@consumer = OAuth::Consumer.new(key, secret, {
:site => "https://api.twitter.com",
:request_token_path => "/oauth/request_token",