Sha256: 1ea9aecf32d955e99690b3813f3b33c03792b0d56d14a8e332deacf9ad542b04

Contents?: true

Size: 926 Bytes

Versions: 2

Compression:

Stored size: 926 Bytes

Contents

#!/usr/bin/env ruby

## This is a very simple working example of a bot using the streaming
## API. It's basically a copy of echoes_bot.rb, just using streaming.

#
# require the dsl lib to include all the methods you see below.
#
require 'rubygems'
require 'chatterbot/dsl'

consumer_secret 'foo'
secret 'bar'
token 'biz'
consumer_key 'bam'


puts "Loading echoes_bot.rb using the streaming API"

exclude "http://", "https://"

blocklist "mean_user, private_user"

use_streaming

replies do |tweet|
  favorite tweet

  puts "It's a tweet!"
  src = tweet.text.gsub(/@echoes_bot/, "#USER#")  
  reply src, tweet
end

direct_messages do |tweet|
  puts "well, here i am #{tweet.text}"
  puts tweet.inspect
  direct_message "got it", tweet.sender
end

favorited do |user, tweet|
  reply "@#{user.screen_name} thanks for the fave!", tweet
end

followed do |user|
  tweet "@#{user.screen_name} just followed me!"
  follow user
end


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chatterbot-2.0.5 examples/streaming_bot.rb
chatterbot-2.0.4 examples/streaming_bot.rb