public override async Task CustomRun(CommandParametersModel parameters) { if (ChannelSession.Settings.QuotesEnabled) { if (ChannelSession.Settings.Quotes.Count > 0) { int quoteNumber = 0; UserQuoteModel quote = null; if (parameters.Arguments.Count() == 1) { if (!int.TryParse(parameters.Arguments.ElementAt(0), out quoteNumber)) { await ChannelSession.Services.Chat.SendMessage("USAGE: !quote [QUOTE NUMBER]"); return; } quote = ChannelSession.Settings.Quotes.SingleOrDefault(q => q.ID == quoteNumber); if (quote == null) { await ChannelSession.Services.Chat.SendMessage($"Unable to find quote number {quoteNumber}."); } } else if (parameters.Arguments.Count() == 0) { int quoteIndex = RandomHelper.GenerateRandomNumber(ChannelSession.Settings.Quotes.Count); quote = ChannelSession.Settings.Quotes[quoteIndex]; } else { await ChannelSession.Services.Chat.SendMessage("USAGE: !quote [QUOTE NUMBER]"); return; } if (quote != null) { await ChannelSession.Services.Chat.SendMessage(quote.ToString()); } } else { await ChannelSession.Services.Chat.SendMessage("At least 1 quote must be added for this feature to work"); } } else { await ChannelSession.Services.Chat.SendMessage("Quotes must be enabled for this feature to work"); } }
public override async Task CustomRun(CommandParametersModel parameters) { if (ChannelSession.Settings.QuotesEnabled) { if (ChannelSession.Settings.Quotes.Count > 0) { UserQuoteModel quote = ChannelSession.Settings.Quotes.LastOrDefault(); if (quote != null) { await ChannelSession.Services.Chat.SendMessage(quote.ToString()); return; } } await ChannelSession.Services.Chat.SendMessage("At least 1 quote must be added for this feature to work"); } else { await ChannelSession.Services.Chat.SendMessage("Quotes must be enabled for this feature to work"); } }
public override async Task CustomRun(CommandParametersModel parameters) { if (ChannelSession.Settings.QuotesEnabled) { if (parameters.Arguments.Count() > 0) { StringBuilder quoteBuilder = new StringBuilder(); foreach (string arg in parameters.Arguments) { quoteBuilder.Append(arg + " "); } string quoteText = quoteBuilder.ToString(); quoteText = quoteText.Trim(new char[] { ' ', '\'', '\"' }); UserQuoteModel quote = new UserQuoteModel(UserQuoteViewModel.GetNextQuoteNumber(), quoteText, DateTimeOffset.Now, ChannelSession.TwitchChannelV5?.game); ChannelSession.Settings.Quotes.Add(quote); await ChannelSession.SaveSettings(); GlobalEvents.QuoteAdded(quote); if (ChannelSession.Services.Chat != null) { await ChannelSession.Services.Chat.SendMessage("Added " + quote.ToString()); } } else { await ChannelSession.Services.Chat.SendMessage("Usage: !addquote <FULL QUOTE TEXT>"); } } else { await ChannelSession.Services.Chat.SendMessage("Quotes must be enabled with Mix It Up for this feature to work"); } }