protected override string ProcessChange() { if (TemplateNode.Name.ToLower() == "learn") { // currently only AIML files in the local filesystem can be referenced // ToDo: Network HTTP and web service based learning if (TemplateNode.InnerText.Length > 0) { string path = TemplateNode.InnerText; FileInfo fi = new FileInfo(path); if (fi.Exists) { XmlDocument doc = new XmlDocument(); try { doc.Load(path); Bot.LoadAIMLFromXML(doc, path); } catch { Bot.WriteToLog("ERROR! Attempted (but failed) to <learn> some new AIML from the following URI: " + path); } } } } return(string.Empty); }
protected override string ProcessChange() { if (TemplateNode.Name.ToLower() == "that") { if (TemplateNode.Attributes.Count == 0) { return(User.GetThat()); } else if (TemplateNode.Attributes.Count == 1) { if (TemplateNode.Attributes[0].Name.ToLower() == "index") { if (TemplateNode.Attributes[0].Value.Length > 0) { try { // see if there is a split string[] dimensions = TemplateNode.Attributes[0].Value.Split(",".ToCharArray()); if (dimensions.Length == 2) { int result = Convert.ToInt32(dimensions[0].Trim()); int sentence = Convert.ToInt32(dimensions[1].Trim()); if ((result > 0) & (sentence > 0)) { return(User.GetThat(result - 1, sentence - 1)); } else { Bot.WriteToLog("ERROR! An input tag with a bady formed index (" + TemplateNode.Attributes[0].Value + ") was encountered processing the input: " + Request.RawInput); } } else { int result = Convert.ToInt32(TemplateNode.Attributes[0].Value.Trim()); if (result > 0) { return(User.GetThat(result - 1)); } else { Bot.WriteToLog("ERROR! An input tag with a bady formed index (" + TemplateNode.Attributes[0].Value + ") was encountered processing the input: " + Request.RawInput); } } } catch { Bot.WriteToLog("ERROR! An input tag with a bady formed index (" + TemplateNode.Attributes[0].Value + ") was encountered processing the input: " + Request.RawInput); } } } } } return(string.Empty); }
protected override string ProcessChange() { if (TemplateNode.Name.ToLower() == "gossip") { // gossip is merely logged by the bot and written to log files if (TemplateNode.InnerText.Length > 0) { Bot.WriteToLog("GOSSIP from user: "******", '" + TemplateNode.InnerText + "'"); } } return(string.Empty); }
protected override string ProcessChange() { if (TemplateNode.Name.ToLower() == "topicstar") { if (TemplateNode.Attributes.Count == 0) { if (Query.TopicStar.Count > 0) { return(Query.TopicStar[0]); } else { Bot.WriteToLog("ERROR! An out of bounds index to topicstar was encountered when processing the input: " + Request.RawInput); } } else if (TemplateNode.Attributes.Count == 1) { if (TemplateNode.Attributes[0].Name.ToLower() == "index") { if (TemplateNode.Attributes[0].Value.Length > 0) { try { int result = Convert.ToInt32(TemplateNode.Attributes[0].Value.Trim()); if (Query.TopicStar.Count > 0) { if (result > 0) { return(Query.TopicStar[result - 1]); } else { Bot.WriteToLog("ERROR! An input tag with a bady formed index (" + TemplateNode.Attributes[0].Value + ") was encountered processing the input: " + Request.RawInput); } } else { Bot.WriteToLog("ERROR! An out of bounds index to topicstar was encountered when processing the input: " + Request.RawInput); } } catch { Bot.WriteToLog("ERROR! A thatstar tag with a bady formed index (" + TemplateNode.Attributes[0].Value + ") was encountered processing the input: " + Request.RawInput); } } } } } return(string.Empty); }
protected override string ProcessChange() { if (TemplateNode.Name.ToLower() == "star") { if (Query.InputStar.Count > 0) { if (TemplateNode.Attributes.Count == 0) { // return the first (latest) star in the List<> return(Query.InputStar[0]); } else if (TemplateNode.Attributes.Count == 1) { if (TemplateNode.Attributes[0].Name.ToLower() == "index") { try { int index = Convert.ToInt32(TemplateNode.Attributes[0].Value); index--; if ((index >= 0) & (index < Query.InputStar.Count)) { return(Query.InputStar[index]); } else { Bot.WriteToLog("InputStar out of bounds reference caused by input: " + Request.RawInput); } } catch { Bot.WriteToLog("Index set to non-integer value whilst processing star tag in response to the input: " + Request.RawInput); } } } } else { Bot.WriteToLog("A star tag tried to reference an empty InputStar collection when processing the input: " + Request.RawInput); } } return(string.Empty); }
protected override string ProcessChange() { Bot.WriteToLog("The javascript tag is not implemented in this bot"); return(string.Empty); }