Sha256: a4b4214c3178650dace26cf31cb46c35e9b48434021d0e0e5b8ca0453d765440

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require_relative 'src/such_streaming_bot.rb'
require "twitter"
require "tweetstream"

Twitter.configure do |config|
  config.consumer_key       = ENV['TWITTER_CONSUMER_KEY']
  config.consumer_secret    = ENV['TWITTER_CONSUMER_SECRET']
  config.oauth_token        = ENV['TWITTER_OAUTH_TOKEN']
  config.oauth_token_secret = ENV['TWITTER_OAUTH_SECRET']
end

TweetStream.configure do |config|
  config.consumer_key       = ENV['TWITTER_CONSUMER_KEY']
  config.consumer_secret    = ENV['TWITTER_CONSUMER_SECRET']
  config.oauth_token        = ENV['TWITTER_OAUTH_TOKEN']
  config.oauth_token_secret = ENV['TWITTER_OAUTH_SECRET']
  config.auth_method        = :oauth
end

loop do
  begin
    puts "starting search"
    TweetStream::Client.new.sample(language: 'en') do |tweet|

      # your bot should have a method called matches?(text)
      # if a tweet passes your matcher, the bot retweets it!

      if SuchStreamingBot.matches? tweet.text
        puts "got one!"
        Twitter.retweet tweet.id
      end
    end
  rescue
    puts 'FAILURE'
  ensure
    sleep 300
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twitter_bot_generator-0.2.3 such_streaming_bot/bot.rb
twitter_bot_generator-0.2.2 such_streaming_bot/bot.rb