require 'drb' class EmoAgent def initialize(callerObj = Object.new) @callerObj = callerObj DRb.start_service() @emobot = DRbObject.new(nil, 'druby://localhost:9130') end def method_missing(input = '') input = input.to_s input.chomp! if input =~ /^gagent/ then return end response, score = @emobot.getResponse(input) if score == nil then score = 1 end if response.to_s =~ /Default response/ then score = 0 end if input =~ /^emo(?:bot|agent)?[:, ]*/i then score += 4 end if response.to_s.strip == '' or response == nil then score = 0 end response = response.to_s.strip if response =~ /^Therefore/ then score += 3 end if response =~ /I will assume/ then score += 3 end if response =~ /Yes, .*->/ then score += 3 end puts "EmoBot: #{response} | #{score}" unless @callerObj.DEBUG == 0 @callerObj.addResponse(["#{response}", score, "emoagent"]) end end