Sha256: fdc2e2709796ea37109bd09bacd3b7299e1a9bfbd10602c10678b912c5b1d1e4

Contents?: true

Size: 929 Bytes

Versions: 2

Compression:

Stored size: 929 Bytes

Contents

require_relative 'src/<%= bot_name %>.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

TweetStream::Client.new.userstream do |tweet|
  puts "@#{tweet.user.screen_name} asks: #{tweet.text}"
  begin
    puts (answer = <%= class_name %>.respond_to tweet.text)
    Twitter.update(answer, :in_reply_to_status_id => tweet.id)
  rescue => e
    puts e
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twitter_bot_generator-0.2.1 lib/twitter_bot_generator/templates/userstream-bot.rb.erb
twitter_bot_generator-0.2.0 lib/twitter_bot_generator/templates/userstream-bot.rb.erb