public override void ExecuteCommand(EvtChatCommandArgs e) { List <string> args = e.Command.ArgumentsAsList; if (args.Count < 3) { BotProgram.MsgHandler.QueueMessage("Usage: \"console\" \"synonymName\" \"input\""); return; } string consoleStr = args[0]; //Check if a valid console is specified if (Enum.TryParse <InputGlobals.InputConsoles>(consoleStr, true, out InputGlobals.InputConsoles console) == false || InputGlobals.Consoles.ContainsKey(console) == false) { BotProgram.MsgHandler.QueueMessage($"Please specify a valid console."); return; } InputSynonymData inputSyns = BotProgram.BotData.InputSynonyms; string synonymName = args[1]; //Get the actual synonym from the remaining arguments string actualSynonym = e.Command.ArgumentsAsString.Remove(0, args[0].Length + 1).Remove(0, args[1].Length + 1); //Add to the dictionary if it doesn't exist if (inputSyns.SynonymDict.TryGetValue(console, out Dictionary <string, string> dict) == false) { dict = new Dictionary <string, string>(8); inputSyns.SynonymDict[console] = dict; } string message = string.Empty; if (dict.ContainsKey(synonymName) == true) { message = $"Updated input synonym \"{synonymName}\" for \"{actualSynonym}\"!"; } else { message = $"Added input synonym \"{synonymName}\" for \"{actualSynonym}\"!"; } //Update value and save bot data dict[synonymName] = actualSynonym; BotProgram.SaveBotData(); BotProgram.MsgHandler.QueueMessage(message); }
public override void ExecuteCommand(EvtChatCommandArgs e) { List <string> args = e.Command.ArgumentsAsList; if (args.Count == 0) { BotProgram.MsgHandler.QueueMessage("Usage: \"console\""); return; } string consoleStr = args[0]; //Check if a valid console is specified if (Enum.TryParse <InputGlobals.InputConsoles>(consoleStr, true, out InputGlobals.InputConsoles console) == false || InputGlobals.Consoles.ContainsKey(console) == false) { BotProgram.MsgHandler.QueueMessage($"Please specify a valid console."); return; } InputSynonymData inputSyns = BotProgram.BotData.InputSynonyms; //Add to the dictionary if it doesn't exist if (inputSyns.SynonymDict.TryGetValue(console, out Dictionary <string, string> dict) == false) { BotProgram.MsgHandler.QueueMessage($"No input synonyms available for console {console}"); return; } StringBuilder sb = new StringBuilder(400); sb.Append("Synonyms for ").Append(console.ToString()).Append(": "); foreach (KeyValuePair <string, string> kvPair in dict) { sb.Append('{').Append(' ').Append(kvPair.Key).Append(',').Append(' ').Append(kvPair.Value).Append(' ').Append('}'); sb.Append(',').Append(' '); } sb.Remove(sb.Length - 2, 2); string message = sb.ToString(); BotProgram.MsgHandler.QueueMessage(message); }
public override void ExecuteCommand(EvtChatCommandArgs e) { List <string> args = e.Command.ArgumentsAsList; if (args.Count != 2) { BotProgram.MsgHandler.QueueMessage("Usage: \"console\" \"synonymName\""); return; } string consoleStr = args[0]; //Check for a valid console if (Enum.TryParse <InputGlobals.InputConsoles>(consoleStr, true, out InputGlobals.InputConsoles console) == false || InputGlobals.Consoles.ContainsKey(console) == false) { BotProgram.MsgHandler.QueueMessage($"Please specify a valid console."); return; } InputSynonymData inputSyns = BotProgram.BotData.InputSynonyms; string synonymName = args[1]; //Check if input synonyms exist for this console if (inputSyns.SynonymDict.TryGetValue(console, out Dictionary <string, string> dict) == false) { BotProgram.MsgHandler.QueueMessage($"No input synonyms exist for console {console}!"); return; } //Remove the synonym if (dict.Remove(synonymName) == false) { BotProgram.MsgHandler.QueueMessage($"No input synonym \"{synonymName}\" exists for console {console}!"); return; } //Save bot data BotProgram.SaveBotData(); BotProgram.MsgHandler.QueueMessage($"Successfully removed input synonym \"{synonymName}\"!"); }