Sha256: 38bd660f0af8afd768ff75fefe24fc2a18adff0c3e98842040fa3941a9a7493f

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

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|

  # your bot should have a method called respond_to(text)
  # when someone tweets @ your bot, it will reply back!
  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.3 lib/twitter_bot_generator/templates/userstream-bot.rb.erb
twitter_bot_generator-0.2.2 lib/twitter_bot_generator/templates/userstream-bot.rb.erb