Пример #1
0
        public void addQuote(string quote, string sender, bool senderIsMod)
        {
            if (quote.Trim() == "")
            {
                return;
            }
            if (Properties.Settings.Default.quotes == null)
            {
                Properties.Settings.Default.quotes = new System.Collections.Specialized.StringCollection();
                Properties.Settings.Default.Save();
            }
            if (quotes == null)
            {
                string[] arrQuotes = new string[Properties.Settings.Default.quotes.Count];
                Properties.Settings.Default.quotes.CopyTo(arrQuotes, 0);
                quotes              = new List <string>(arrQuotes);
                quoteTimer.Elapsed += QuoteTimer_Elapsed;
            }
            if (addingQuote)
            {
                ChatHandler.sendMessage("Finish adding the current quote first.");
                return;
            }

            quoteToAdd = quote;

            if (Properties.Settings.Default.quoteVotersNumber == 0)
            {
                Properties.Settings.Default.quotes.Add(quoteToAdd);
                Properties.Settings.Default.Save();
                quotes.Add(quoteToAdd);
                ChatHandler.sendMessage("Quote added.");
                return;
            }

            else
            {
                addingQuote = true;
                quoteTimer.Start();
                ChatHandler.sendMessage((Properties.Settings.Default.quoteVotersNumber - 1).ToString() +
                                        " other " + (Properties.Settings.Default.quoteVotersNumber > 2 ? "people need" : "person needs") + " to agree by typing " +
                                        Properties.Settings.Default.prefix +
                                        ChatHandler.getVoteYesCommand() +
                                        " to add the quote! Ends in one minute.");
                quoteAdders.Add(sender);
            }
        }