Exemple #1
0
 public static void QuoteAdded(UserQuoteModel quote)
 {
     if (GlobalEvents.OnQuoteAdded != null)
     {
         GlobalEvents.OnQuoteAdded(null, quote);
     }
 }
Exemple #2
0
 private void GlobalEvents_OnQuoteAdded(object sender, UserQuoteModel quote)
 {
     this.Dispatcher.BeginInvoke(new Action(() =>
     {
         this.viewModel.Refresh();
     }));
 }
 public static Quote QuoteFromUserQuoteViewModel(UserQuoteModel quoteData)
 {
     return(new Quote
     {
         ID = quoteData.ID,
         DateTime = quoteData.DateTime,
         GameName = quoteData.GameName,
         QuoteText = quoteData.Quote,
     });
 }
        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");
            }
        }
        public async Task <Quote> Add([FromBody] AddQuote quote)
        {
            if (quote == null || quote.QuoteText.IsNullOrEmpty())
            {
                var resp = new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new ObjectContent <Error>(new Error {
                        Message = $"Unable to create quote, no QuoteText was supplied."
                    }, new JsonMediaTypeFormatter(), "application/json"),
                    ReasonPhrase = "QuoteText not specified"
                };
                throw new HttpResponseException(resp);
            }

            var            quoteText = quote.QuoteText.Trim(new char[] { ' ', '\'', '\"' });
            UserQuoteModel newQuote  = new UserQuoteModel(UserQuoteViewModel.GetNextQuoteNumber(), quoteText, DateTimeOffset.Now, ChannelSession.TwitchChannelV5?.game);

            ChannelSession.Settings.Quotes.Add(newQuote);
            await ChannelSession.SaveSettings();

            GlobalEvents.QuoteAdded(newQuote);

            return(QuoteFromUserQuoteViewModel(newQuote));
        }
Exemple #8
0
 public UserQuoteViewModel(string quote, DateTimeOffset dateTime, string gameName = null)
 {
     this.Model = new UserQuoteModel(UserQuoteViewModel.GetNextQuoteNumber(), quote, dateTime, gameName);
 }
Exemple #9
0
 public UserQuoteViewModel(UserQuoteModel model)
 {
     this.Model = model;
 }