Skip to content

Instantly share code, notes, and snippets.

@emad-elsaid
Created February 23, 2014 10:41
Show Gist options
  • Save emad-elsaid/9169810 to your computer and use it in GitHub Desktop.
Save emad-elsaid/9169810 to your computer and use it in GitHub Desktop.
twitter bot to auto favourite tweets
require 'Twitter' #gem install twitter
while true
begin
# Create a read write application from :
# https://apps.twitter.com
# authenticate it for your account
# fill in the following
config = {
consumer_key: '',
consumer_secret: '',
access_token: '',
access_token_secret: ''
}
rClient = Twitter::REST::Client.new config
sClient = Twitter::Streaming::Client.new(config)
# topics to watch
topics = ['#rails', '#ruby', '#coding', '#codepen']
sClient.filter(:track => topics.join(',')) do |tweet|
if tweet.is_a?(Twitter::Tweet)
puts tweet.text
rClient.fav tweet
end
end
rescue
puts 'error occurred, waiting for 5 seconds'
sleep 5
end
end
@drwn
Copy link

drwn commented Dec 3, 2014

For future reference: This is ruby 1.9.x, it's also not require 'Twitter', it's require 'twitter'

@mws67
Copy link

mws67 commented Apr 1, 2015

how can we filter the tweets by location? Is there a geolocation function we could use with lat/lon? thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment