Skip to content

Instantly share code, notes, and snippets.

@muffinista
Forked from squarism/bot.rb
Created November 23, 2011 00:58
Show Gist options
  • Save muffinista/1387606 to your computer and use it in GitHub Desktop.
Save muffinista/1387606 to your computer and use it in GitHub Desktop.
bot reply test
$LOAD_PATH.unshift File.dirname(__FILE__) + "/lib"
require 'chatterbot/dsl'
require 'pokerthing'
exclude "http://" # block spam tweet
blacklist "jerkface, assbutt" # block jerks or self
#debug_mode true
puts "Bot listening."
loop do
trap('TERM') { puts 'Exiting...'; $exit = true }
trap('INT') { puts 'Exiting...'; $exit = true }
break if $exit
replies do |tweet|
puts "got tweet from @#{tweet[:user][:screen_name]}!"
puts " it says: #{tweet[:text]}"
# debug
File.open('tweet.dat', 'w+') do |f|
Marshal.dump(tweet, f)
#exit
end
tweet_text = tweet[:text].to_s
tweet_array = tweet_text.gsub(/@echoes_bot/,'').lstrip.squeeze.split(' ')
if tweet_array[0] == 'test'
hand_text = "#USER# my great message"
reply hand_text, tweet
else
puts "spam"
end
end
sleep 2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment