mirror of
https://github.com/thewesker/twitter_ebooks.git
synced 2025-12-20 12:21:11 -05:00
Bot can now respond to favorite events.
I wrote this for myself, but I thought I would share!
This commit is contained in:
@@ -257,11 +257,18 @@ module Ebooks
|
|||||||
log "DM from @#{ev.sender.screen_name}: #{ev.text}"
|
log "DM from @#{ev.sender.screen_name}: #{ev.text}"
|
||||||
fire(:message, ev)
|
fire(:message, ev)
|
||||||
|
|
||||||
elsif ev.respond_to?(:name) && ev.name == :follow
|
elsif ev.respond_to?(:name)
|
||||||
|
if ev.name == :follow
|
||||||
return if ev.source.screen_name.downcase == @username.downcase
|
return if ev.source.screen_name.downcase == @username.downcase
|
||||||
log "Followed by #{ev.source.screen_name}"
|
log "Followed by #{ev.source.screen_name}"
|
||||||
fire(:follow, ev.source)
|
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
|
elsif ev.is_a? Twitter::Tweet
|
||||||
return unless ev.text # If it's not a text-containing tweet, ignore it
|
return unless ev.text # If it's not a text-containing tweet, ignore it
|
||||||
return if ev.user.screen_name.downcase == @username.downcase # Ignore our own tweets
|
return if ev.user.screen_name.downcase == @username.downcase # Ignore our own tweets
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ class MyBot < Ebooks::Bot
|
|||||||
# Reply to a tweet in the bot's timeline
|
# Reply to a tweet in the bot's timeline
|
||||||
# reply(tweet, "nice tweet")
|
# reply(tweet, "nice tweet")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def on_favorite(user, tweet)
|
||||||
|
# Follow user who just favorited bot's tweet
|
||||||
|
# follow(user.screen_name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Make a MyBot and attach it to an account
|
# Make a MyBot and attach it to an account
|
||||||
|
|||||||
Reference in New Issue
Block a user