public override void Initialize() { base.Initialize(); if (UserExercises == null) { UserExercises = new ConcurrentDictionary <string, InputExercise>(Environment.ProcessorCount * 2, 32); } //Split inputs by what's in the value string if (string.IsNullOrEmpty(ValueStr) == false) { InvalidExerciseInputNames = ValueStr.Split(SPLIT_CHAR, StringSplitOptions.RemoveEmptyEntries); //Trim whitespace for (int i = 0; i < InvalidExerciseInputNames.Length; i++) { InvalidExerciseInputNames[i] = InvalidExerciseInputNames[i].Trim(); } } }
public override void ExecuteCommand(EvtChatCommandArgs args) { //Values are separated by the pipe character, '|' //Replace "{name}" with the user's name string userName = args.Command.ChatMessage.Username; //Allow inspiring another user List <string> arguments = args.Command.ArgumentsAsList; if (arguments.Count == 1) { //Check if the name is in the database User user = DataHelper.GetUser(arguments[0]); if (user != null) { userName = user.Name; } } string[] inspirationArray = DefaultInspiration; if (string.IsNullOrEmpty(ValueStr) == false) { string[] newInspirationArray = ValueStr.Split(SPLIT_CHAR, StringSplitOptions.RemoveEmptyEntries); //Use the array from the values if there are elements if (newInspirationArray.Length > 0) { inspirationArray = newInspirationArray; } } int randInspiration = Rand.Next(0, inspirationArray.Length); string inspirationMsg = inspirationArray[randInspiration]; string message = inspirationMsg.Replace(NAME_REPLACE, userName); QueueMessage(message); }