public override void OnInvoke(object sender, System.EventArgs e, object target) { ListViewItem ali = target as ListViewItem; string username = null; UUID uuid = UUID.Zero; if (ali != null) { uuid = (UUID)ali.Tag; username = instance.Names.Get(uuid); } else { FriendInfo fi = target as FriendInfo; uuid = fi.UUID; username = instance.Names.Get(uuid); } if (username == null) { instance.TabConsole.DisplayNotificationInChat("I dont know how to DeRef " + target + " bieng a " + target.GetType()); return; } string outp = username + ", " + aimlBot.Chat("INTERJECTION", username).Output; if (outp.Length > 1000) { outp = outp.Substring(0, 1000); } Client.Self.Chat(outp, 0, ChatType.Normal); }
/// <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); }
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(); }