Sha256: 965d8ca749528851e63b40d39004f6fbfbe476ba2bacc5bb9d380fdc3019fc97

Contents?: true

Size: 922 Bytes

Versions: 7

Compression:

Stored size: 922 Bytes

Contents

#!/usr/bin/env ruby

## This is a very simple working example of a bot you can build with
## chatterbot. It looks for mentions of '@echoes_bot' (the twitter
## handle the bot uses), and sends replies with the name switched to
## the handle of the sending user

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

puts "Loading echoes_bot.rb"

##
## If I wanted to exclude some terms from triggering this bot, I would list them here.
## For now, we'll block URLs to keep this from being a source of spam
##
exclude "http://"

blocklist "mean_user, private_user"

puts "checking for replies to me"
replies do |tweet|
  # replace the incoming username with #USER#, which will be replaced
  # with the handle of the user who tweeted us by the
  # replace_variables helper
  src = tweet.text.gsub(/@echoes_bot/, "#USER#")  

  # send it back!
  reply src, tweet
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chatterbot-2.2.0 examples/echoes_bot.rb
chatterbot-2.1.0 examples/echoes_bot.rb
chatterbot-2.0.5 examples/echoes_bot.rb
chatterbot-2.0.4 examples/echoes_bot.rb
chatterbot-2.0.3 examples/echoes_bot.rb
chatterbot-2.0.2 examples/echoes_bot.rb
chatterbot-2.0.0.pre examples/echoes_bot.rb