require 'drb' class GAgent def initialize(callerObj = Object.new) @callerObj = callerObj DRb.start_service() @gagent = DRbObject.new(nil, 'druby://localhost:9011') # actually gagentbot end def method_missing(input = '') input = input.to_s input.chomp! if input =~ /^(?:emoagent|emobot)/ then return end response, score = @gagent.getResponse(input) if score == nil then score = 1 end if response =~ /Default response/ then score = 0 end if response =~ /because/ then score += 1 end if response =~ /Yes/ then score += 1 end if response =~ /Okay/ then score -= 2 end #if response =~ /I have no knowledge/ then score -= 1 end if input =~ /(?:gagent|gabot|gagentbot|logic agent|logicagent|lagent)/i score += 2 end if response == nil or response.strip == '' then score -= 2 end puts "GAgent: #{response} | #{score}" unless @callerObj.DEBUG == 0 @callerObj.addResponse(["#{response}", score, "gagent"]) end end