Skip to content

Instantly share code, notes, and snippets.

@squarism
Created November 21, 2011 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save squarism/1382987 to your computer and use it in GitHub Desktop.
Save squarism/1382987 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(/@echobot/,'').lstrip.squeeze.split(' ')
if tweet_array[0] == 'test'
hand_text = "my great message"
src = tweet[:text].gsub(/@echobot/, tweet_user(tweet))
tweet[:text] = "#{tweet_user(tweet)} #{hand_text}"
reply src, tweet
puts "replied with #{tweet} to #{tweet_user(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