Created
December 21, 2010 15:58
-
-
Save victorpimentel/750105 to your computer and use it in GitHub Desktop.
Quick Twitter bot for following people that tweet about a certain phrase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'open-uri' | |
require 'hpricot' | |
require 'twitter' | |
doc = Hpricot(open('http://wikipedal.org/', 'User-Agent' => 'ruby')) | |
cocktail = (doc / '#mp-tfa .mw-headline').text.strip | |
Twitter.configure do |config| | |
config.consumer_key = 'YOUR_CONSUMER_KEY' | |
config.consumer_secret = 'YOUR_CONSUMER_SECRET' | |
config.oauth_token = 'YOUR_OATH_TOKEN' | |
config.oauth_token_secret = 'YOUR_OATH_TOKEN_SECRET' | |
end | |
search = Twitter::Search.new | |
search.containing(cocktail).language('es').not_from('Wikipedal').not_mentioning('Wikipedal').no_retweets.per_page(10).each do |tweet| | |
user = Twitter.user(tweet.from_user) | |
if !user.following && user.followers_count > 100 && user.friends_count > 100 | |
Twitter.follow(user.screen_name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment