/// <summary> /// Simple Chat function. Processes Input /// and returns output. /// </summary> /// <param name="input">Input.</param> public string Chat(string input) { // Debugging if (debug) { Debug.Log(input); } // Build request request.rawInput = input; // Time when chat begins to handle // timeout errors request.StartedOn = DateTime.Now; // Perform chat if bot exists if (bot != null) { result = bot.Chat(request); } else { // Else throw warning Debug.LogWarning("Can't retrieve AIMLbot.Bot bot. Did you initialize Chatbot correct?"); } // Debugging if (debug) { Debug.Log(result.Output); } return(result.Output); }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot involved in this request</param> /// <param name="user">The user making the request</param> /// <param name="query">The query that originated this node</param> /// <param name="request">The request inputted into the system</param> /// <param name="result">The result to be passed to the user</param> /// <param name="templateNode">The node to be processed</param> public system(AIMLbot.Bot bot, AIMLbot.User user, AIMLbot.Utils.SubQuery query, AIMLbot.Request request, AIMLbot.Result result, XmlNode templateNode) : base(bot, user, query, request, result, templateNode) { }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot involved in this request</param> /// <param name="user">The user making the request</param> /// <param name="query">The query that originated this node</param> /// <param name="request">The request inputted into the system</param> /// <param name="result">The result to be passed to the user</param> /// <param name="templateNode">The node to be processed</param> public sentence(Bot bot, AIMLbot.User user, Utils.SubQuery query, Request request, AIMLbot.Result result, XmlNode templateNode) : base(bot, user, query, request, result, templateNode) { }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot involved in this request</param> /// <param name="user">The user making the request</param> /// <param name="query">The query that originated this node</param> /// <param name="request">The request inputted into the system</param> /// <param name="result">The result to be passed to the user</param> /// <param name="templateNode">The node to be processed</param> public condition(AIMLbot.Bot bot, AIMLbot.User user, AIMLbot.Utils.SubQuery query, AIMLbot.Request request, AIMLbot.Result result, XmlNode templateNode) : base(bot, user, query, request, result, templateNode) { this.isRecursive = false; }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot involved in this request</param> /// <param name="user">The user making the request</param> /// <param name="query">The query that originated this node</param> /// <param name="request">The request inputted into the system</param> /// <param name="result">The result to be passed to the user</param> /// <param name="templateNode">The node to be processed</param> public random(Bot bot, AIMLbot.User user, Utils.SubQuery query, Request request, AIMLbot.Result result, XmlNode templateNode) : base(bot, user, query, request, result, templateNode) { isRecursive = false; }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot involved in this request</param> /// <param name="user">The user making the request</param> /// <param name="query">The query that originated this node</param> /// <param name="request">The request inputted into the system</param> /// <param name="result">The result to be passed to the user</param> /// <param name="templateNode">The node to be processed</param> public javascript(AIMLbot.Bot bot, AIMLbot.User user, AIMLbot.Utils.SubQuery query, AIMLbot.Request request, AIMLbot.Result result, XmlNode templateNode) : base(bot, user, query, request, result, templateNode) { // Preprocess javascript, return result and then process result this.isRecursive = false; }
private void button1_Click_1(object sender, EventArgs e) { textBox1.Text = textBox1.Text.Trim(); if (textBox1.Text == string.Empty) { return; } AIMLbot.Request req = new AIMLbot.Request(textBox1.Text, _user, _bot); tbLog.AppendText("You> " + textBox1.Text); tbLog.AppendText(Environment.NewLine); AIMLbot.Result r = _bot.Chat(req); string unfilteredResp = r.Output; string resp = string.Empty; string[] cmds = Common.GetTextBetween(unfilteredResp, out resp, '[', ']'); resp = resp.Replace("\r", string.Empty); resp = resp.Replace("\n", string.Empty); resp = EZ_Builder.Scripting.VariableManager.SubsituteWithValues(resp); resp = resp.Replace("\"", ""); resp = Regex.Replace(resp, @"\s+", " "); tbLog.AppendText("Bot> " + resp); tbLog.AppendText(Environment.NewLine); EZ_Builder.Scripting.VariableManager.SetVariable( _cf.STORAGE[ConfigTitles.RESPONSE_VARIABLE].ToString(), resp); if (_cf.STORAGE[ConfigTitles.RESPONSE_SCRIPT].ToString() != string.Empty) { EZ_Builder.Scripting.EZScriptManager.GetExecutor(_EXECUTOR_NAME).StartScriptASync(_cf.STORAGE[ConfigTitles.RESPONSE_SCRIPT].ToString()); } foreach (string cmd in cmds) { Invokers.SetAppendText(tbLog, true, 50, "Exec: {0}", cmd); string response = EZ_Builder.Scripting.EZScriptManager.GetExecutor(_EXECUTOR_NAME + "_embedded").ExecuteScriptSingleLine(cmd); if (response != string.Empty) { Invokers.SetAppendText(tbLog, true, 50, response); } } textBox1.Clear(); }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot involved in this request</param> /// <param name="user">The user making the request</param> /// <param name="query">The query that originated this node</param> /// <param name="request">The request itself</param> /// <param name="result">The result to be passed back to the user</param> /// <param name="templateNode">The node to be processed</param> public AIMLTagHandler(AIMLbot.Bot bot, AIMLbot.User user, AIMLbot.Utils.SubQuery query, AIMLbot.Request request, AIMLbot.Result result, XmlNode templateNode) : base(bot, templateNode.OuterXml) { this.user = user; this.query = query; this.request = request; this.result = result; this.templateNode = templateNode; }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot involved in this request</param> /// <param name="user">The user making the request</param> /// <param name="query">The query that originated this node</param> /// <param name="request">The request itself</param> /// <param name="result">The result to be passed back to the user</param> /// <param name="templateNode">The node to be processed</param> public AIMLTagHandler(Bot bot, AIMLbot.User user, AIMLbot.Utils.SubQuery query, Request request, AIMLbot.Result result, XmlNode templateNode) : base(bot, templateNode.OuterXml) { this.user = user; this.query = query; this.request = request; this.result = result; this.templateNode = templateNode; this.templateNode.Attributes.RemoveNamedItem("xmlns"); }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot involved in this request</param> /// <param name="user">The user making the request</param> /// <param name="query">The query that originated this node</param> /// <param name="request">The request itself</param> /// <param name="result">The result to be passed back to the user</param> /// <param name="templateNode">The node to be processed</param> public AIMLTagHandler( AIMLbot.Bot bot, AIMLbot.User user, AIMLbot.Utils.SubQuery query, AIMLbot.Request request, AIMLbot.Result result, XmlNode templateNode) : base(bot,templateNode.OuterXml) { this.user = user; this.query = query; this.request = request; this.result = result; this.templateNode = templateNode; }
/// <summary> /// Initializes a new instance of the <see cref="Chatbot.Trigger"/> class. /// </summary> /// <param name="Chatbot">Chatbot.</param> public void Initialize(GameObject tmpchatbot) { // Save delivered GameObject chatbot = tmpchatbot; // Throw error if not Game Object delivered if (!chatbot) { Debug.LogWarning("To use chatbot you need to attatch ChatbotCore.cs script to a GameObject and pass GameObject to Chatbot. GameObject is empty."); } // Windows, Linux and Mac OSX #if !(UNITY_WEBPLAYER || UNITY_WEBGL) else { // Initialize Program # variables bot = new AIMLbot.Bot(this); user = new AIMLbot.User("User", bot); request = new AIMLbot.Request("", user, bot); result = new AIMLbot.Result(user, bot, request); // Global Settings Setting[] settings; // Gather all attatched settings from Scene settings = chatbot.GetComponentsInChildren <Setting>(); // Loop through settings and foreach (Setting setting in settings) { // Set global settings in Program# and Jurassic SetGlobalSetting(setting.gameObject.name, setting.value); } // Load Settings from Scene Setting Components. bot.loadSettingsFromScene(); // Load AIML files from AIML path defined in Settings.xml bot.loadAIMLFromFiles(); // Define to or not to use JavaScript (Jurassic) in AIML bot.UseJavaScript = true; // Use Program # with Jurassic and Chatbot bot.ProgramSharpJSWithChatbot = true; // Create Triggers instance trigger = new Chatbot.Triggers(); // Initializes triggers that are attatched // to the Chatbot. Needs to pass the // Chatbot Gameobject and Triggers instance trigger.Initialize(chatbot, this); // Create Motives instance motive = new Chatbot.Motives(); // Initialize it motive.Initialize(chatbot); // Create Planner instance planner = new Chatbot.NestedPlanner(); // Initialize planner planner.Initialize(chatbot, this, motive); } #else // Webplayer plattform or WebGl ProgramSharpWebplayerCoroutine WebplayerCoroutine = chatbot.GetComponent <ProgramSharpWebplayerCoroutine>(); if (WebplayerCoroutine != null && chatbot != null) { // Load settings from scene bot = new AIMLbot.Bot(WebplayerCoroutine, Application.dataPath + "/Chatbot/Program #/advancedconfig/Settings.xml", true, this); user = new AIMLbot.User("User", bot); request = new AIMLbot.Request("", user, bot); result = new AIMLbot.Result(user, bot, request); // Define to or not to use JavaScript (Jurassic) in AIML bot.UseJavaScript = true; // Use Program # with Jurassic and Chatbot bot.ProgramSharpJSWithChatbot = true; // Create Triggers instance trigger = new Chatbot.Triggers(); // Initializes triggers that are attatched // to the Chatbot. Needs to pass the // Chatbot Gameobject and Triggers instance trigger.Initialize(chatbot, this); // Create Motives instance motive = new Chatbot.Motives(); // Initialize it motive.Initialize(chatbot); // Create Planner instance planner = new Chatbot.NestedPlanner(); // Initialize planner planner.Initialize(chatbot, this, motive); } else { Debug.LogWarning("You need to attatch the Webplayer Component in Webplayer plattform mode."); } #endif }