public override IList <Response> Execute(SenderSettings senderDetail, IMessageDetail args) { ServerSettings serverSettings = senderDetail.ServerSettings; CommandMessageHelper command = new CommandMessageHelper(serverSettings.CommandSymbol, args.Message); // First, substitute the variables. string message = VariableStrings.Replace(command.CommandDetail, args.Username, args.UserId.ToString(), args.GuildName, command.CommandDetail); if (string.IsNullOrWhiteSpace(message)) { // Use the command's name instead. message = command.FullCommandExcludingCommandPrefix; } // Shrug. message = message.StripAccents(); // Now substitute the replacements from the table. StringBuilder sb = new StringBuilder(); foreach (char c in message) { string letter = c.ToString(); foreach (var replacementPair in replaceTable) { letter = letter.Replace(replacementPair.Key, replacementPair.Value, (ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)); // If a replacement was made. if (letter != c.ToString()) { break; } } sb.Append(letter); } string output = reverse ? new string(sb.ToString().Reverse().ToArray()) : sb.ToString(); List <Response> responses = new List <Response> { new Response { Embed = null, Message = output, ResponseType = ResponseType.Default } }; if (doTTS) { responses.Add( new Response { Embed = null, Message = output, ResponseType = ResponseType.Default_TTS } ); } return(responses.ToArray()); }
public override IList <Response> Execute(SenderSettings senderDetail, IMessageDetail args) { ServerSettings serverSettings = senderDetail.ServerSettings; CommandMessageHelper command = new CommandMessageHelper(serverSettings.CommandSymbol, args.Message); string choice = choices[rand.Next(choices.Length)]; string result = VariableStrings.Replace(choice, args.Username, args.UserId.ToString(), args.GuildName, command.CommandDetail); Response response = new Response { Embed = null, Message = result, ResponseType = responseType }; return(new[] { response }); }
public override IList <Response> Execute(SenderSettings senderDetail, IMessageDetail args) { ServerSettings serverSettings = senderDetail.ServerSettings; CommandMessageHelper command = new CommandMessageHelper(serverSettings.CommandSymbol, args.Message); StringBuilder choice = new StringBuilder(choiceFormat); for (int i = 0; i < choices.Length; i++) { choice.Replace($"{{{i}}}", choices[i][rand.Next(choices[i].Length)]); } string result = VariableStrings.Replace(choice, args.Username, args.UserId.ToString(), args.GuildName, command.CommandDetail).ToString(); Response response = new Response { Embed = null, Message = result, ResponseType = responseType }; return(new[] { response }); }