Created
November 21, 2011 15:41
-
-
Save squarism/1382987 to your computer and use it in GitHub Desktop.
bot reply test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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