diff --git a/ShiftOS.Frontend/Apps/ChatClient.cs b/ShiftOS.Frontend/Apps/ChatClient.cs index cac665c..1f685dc 100644 --- a/ShiftOS.Frontend/Apps/ChatClient.cs +++ b/ShiftOS.Frontend/Apps/ChatClient.cs @@ -93,6 +93,13 @@ namespace ShiftOS.Frontend.Apps //Let's try the AI stuff... :P var rmsg = _messages[rnd.Next(_messages.Count)].Message; + if (!messagecache.Contains(_messages.Last().Message)) + { + messagecache.Add(_messages.Last().Message); +#if RIP_USERS_SSD + SaveCache(); +#endif + } var split = new List(rmsg.Split(' ')); List nmsg = new List(); if (split.Count > 2) @@ -109,10 +116,10 @@ namespace ShiftOS.Frontend.Apps { split.RemoveAt(i); } - split.AddRange(Regex.Split(Regex.Replace(_messages[rnd.Next(_messages.Count)].Message, "debugbot", outcomes[rnd.Next(outcomes.Length)], RegexOptions.IgnoreCase), " ")); + split.AddRange(Regex.Split(Regex.Replace(messagecache[rnd.Next(messagecache.Count)], "debugbot", outcomes[rnd.Next(outcomes.Length)], RegexOptions.IgnoreCase), " ")); } split.RemoveAt(rnd.Next(split.Count)); - split.Add(Regex.Replace(_messages[rnd.Next(_messages.Count)].Message, "debugbot", outcomes[rnd.Next(outcomes.Length)], RegexOptions.IgnoreCase)); + split.Add(Regex.Replace(messagecache[rnd.Next(messagecache.Count)], "debugbot", outcomes[rnd.Next(outcomes.Length)], RegexOptions.IgnoreCase)); string combinedResult = string.Join(" ", split); _messages.Add(new ChatMessage { @@ -125,7 +132,7 @@ namespace ShiftOS.Frontend.Apps readonly string[] outcomes = new string[] { "ok", "sure", "yeah", "yes", "no", "nope", "alright" }; Random rnd = new Random(); - List messagecache = new List(); + private List messagecache = new List(); public void SendClientMessage(string nick, string message) { @@ -168,21 +175,30 @@ namespace ShiftOS.Frontend.Apps } gfx.DrawRectangle(vertSeparatorLeft, 0, 1, _bottomseparator, UIManager.SkinTextures["ControlTextColor"]); } - + public void OnLoad() { - + if (System.IO.File.Exists("aicache.dat")) + messagecache = System.IO.File.ReadAllLines("aicache.dat").ToList(); } public void OnSkinLoad() { } - + public bool OnUnload() { + // this doesn't get called... dammit + SaveCache(); return true; } + private void SaveCache() + { + // It's watching you... + System.IO.File.WriteAllLines("aicache.dat", messagecache); + } + public void OnUpgrade() { } diff --git a/ShiftOS_TheReturn/CommandParser.cs b/ShiftOS_TheReturn/CommandParser.cs index 8f25668..f234aca 100644 --- a/ShiftOS_TheReturn/CommandParser.cs +++ b/ShiftOS_TheReturn/CommandParser.cs @@ -85,16 +85,22 @@ namespace ShiftOS.Engine int commandPos; int firstValuePos = -1; int lastValuePos = -1; - + int firstTextPart = -1; for (int ii = 0; ii < parts.Count; ii++) { CommandFormat part = parts[ii]; + if(part is CommandFormatText) + { + if(firstTextPart < 0) + firstTextPart = ii; + } if (part is CommandFormatMarker) { if (part is CommandFormatCommand) { commandPos = ii; } + else if (part is CommandFormatValue) { if (firstValuePos > -1) @@ -110,40 +116,44 @@ namespace ShiftOS.Engine int help = -1; bool id_found = false; string id_text = ""; - while (position < text.Length) { if (i >= parts.Count) { - position = text.Length; - command = "+FALSE+"; - i = 0; + i = 1; } - CommandFormat part = parts[i]; + var part = parts[i]; string inp = text.Substring(position); + string res = part.CheckValidity(inp); - if(part is CommandFormatText) + if (part is CommandFormatText) { if (res == "+FALSE+") { -#if SUPERMOSQUITO_DIAGNOSIS - if (!inp.Remove(0, 1).Contains(" ")) + if (id_found == false) { - - - if (id_found == false) + id_found = true; + currentArgument = "id"; + if (!arguments.ContainsKey("id")) { - id_found = true; - id_text = inp.Remove(0, 1); - res = ""; - arguments.Add("id", id_text); - + arguments.Add("id", ""); + i = firstValuePos; + position++; + continue; } + else + { + Console.WriteLine("Duplicate command-line argument detected: id"); + command = "+FALSE+"; + position = text.Length; + + } + } -#endif } + } // ok so: