Bot can now respond to favorite events.

I wrote this for myself, but I thought I would share!
This commit is contained in:
Stawberri 2015-01-06 21:40:17 -08:00
parent 235684d8f1
commit 3cea0c83e2
2 changed files with 16 additions and 4 deletions

View file

@ -257,10 +257,17 @@ module Ebooks
log "DM from @#{ev.sender.screen_name}: #{ev.text}"
fire(:message, ev)
elsif ev.respond_to?(:name) && ev.name == :follow
return if ev.source.screen_name.downcase == @username.downcase
log "Followed by #{ev.source.screen_name}"
fire(:follow, ev.source)
elsif ev.respond_to?(:name)
if ev.name == :follow
return if ev.source.screen_name.downcase == @username.downcase
log "Followed by #{ev.source.screen_name}"
fire(:follow, ev.source)
elsif ev.name == :favorite || ev.name == :unfavorite
return if ev.source.screen_name.downcase == @username.downcase # Ignore our own favorites
log "@#{ev.source.screen_name} #{ev.name.to_s}d: #{ev.target_object.text}"
fire(ev.name, ev.source, ev.target_object)
end
elsif ev.is_a? Twitter::Tweet
return unless ev.text # If it's not a text-containing tweet, ignore it

View file

@ -46,6 +46,11 @@ class MyBot < Ebooks::Bot
# Reply to a tweet in the bot's timeline
# reply(tweet, "nice tweet")
end
def on_favorite(user, tweet)
# Follow user who just favorited bot's tweet
# follow(user.screen_name)
end
end
# Make a MyBot and attach it to an account