Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (38 sloc) 1.08 KB
require 'tweetstream'
require 'yaml'
require 'sidekiq'
require './workers/new_tweet'
require './workers/reply_tweet'
require './workers/retweet'
class Array
def extract_options!
if last.is_a?(Hash) && last.extractable_options?
pop
else
{}
end
end
end
config = YAML.load_file('config.yml')
TweetStream.configure do |c|
c.consumer_key = config['twitter']['consumer_key']
c.consumer_secret = config['twitter']['consumer_secret']
c.oauth_token = config['twitter']['oauth_token']
c.oauth_token_secret = config['twitter']['oauth_token_secret']
c.auth_method = :oauth
end
TweetStream::Daemon.new('feeder', :log_output => true, :multiple => true).track(config['twitter']['hashtags']) do |status|
s = status.attrs.to_json
unless status.from_user == 'ombuduy'
if status.retweeted_status
puts 'es un retweet'
Retweet.perform_async(config, s)
elsif status.reply?
puts 'es un reply'
NewTweet.perform_async(config, s)
else
puts 'es uno nuevo'
ReplyTweet.perform_async(config, s)
end
end
end