class WeaverBot::Perform

Public Class Methods

chatbot() click to toggle source

I haven't included Write Renpy Script, as that still need to be bug tested.

# File lib/WeaverBot.rb, line 27
    def self.chatbot
      require "programr"

      bot_name = File.read("data/bot_identity/name.txt").strip
      usr_name = File.read("data/usr_identity/name.txt").strip

      brains = Dir.glob("Chatbots/*")

      robot = ProgramR::Facade.new
      robot.learn(brains)

      puts " Welcome to #{bot_name}. This is the terminal for my chatbot."

      while true
        print "#{usr_name } >> "
        s = STDIN.gets.chomp

        reaction = robot.get_reaction(s)

        if    reaction == ""
          STDOUT.puts "#{bot_name} << I have no idea."
#        elsif reaction ==        "Lets check the hours."; WeaverBot::AIRulesets.give_hours
#        elsif reaction ==    "Lets do Tesla arithmetic."; WeaverBot::AIRulesets.tesla_multiplication
#        elsif reaction ==  "Lets give a morning prompt."; WeaverBot::AIRulesets.autonomous_prompting
#        elsif reaction ==    "Lets measure a hypercube."; WeaverBot::AIRulesets.calculate_hyper
#        elsif reaction ==   "Lets estimate digest size."; WeaverBot::AIRulesets.estimate_digest
#        elsif reaction ==      "Lets write some poetry."; WeaverBot::AIRulesets.write_poetry
#        elsif reaction ==            "Lets draw a line."; WeaverBot::AIRulesets.line
#        elsif reaction ==          "Lets draw a square."; WeaverBot::AIRulesets.square
#        elsif reaction ==            "Lets draw a cube."; WeaverBot::AIRulesets.cube
#        elsif reaction ==           "Lets draw a hyper."; WeaverBot::AIRulesets.hyper
#        elsif reaction ==           "Lets draw a image."; WeaverBot::AIRulesets.image
        elsif reaction == "Lets study a language model."; WeaverBot::MachineLearning.language_model
        elsif reaction ==                      "Closing"; MyBot::Purge.old_data; abort
        else
          STDOUT.puts "#{bot_name} << #{reaction}"
        end
      end
    end