Beispiel #1
0
        void OnChannelMessage(object sender, IrcEventArgs e)
        {
            try
            {
                //Message zusammenbauen
                string cbMessage="";

                foreach(string i in e.Data.MessageArray)
                {
                    cbMessage+=i+" ";
                }

                cbMessage=cbMessage.Trim();

                //Message auswerten
                if(cbMessage=="!highscore")
                {
                    if(highscore.Count==0)
                    {
                        SendMessage("Die Highscore ist zur Zeit leer.");
                    }
                    else
                    {
                        SendMessage("Die aktuelle Highscore sieht wie folgt aus:");

                        List<string> highscoreAsList=highscore.GetHighscoreSortedByPoints();
                        foreach(string entry in highscoreAsList)
                        {
                            SendMessage(entry);
                        }
                    }
                }
                else if(cbMessage=="!info")
                {
                    SendMessage("Ich bin Arbiter und wurde 2013 am Lambert Institute von seeseekey entwickelt. Meine Versionskennung lautet {0}.", version);
                }
                else if(cbMessage=="!help")
                {
                    SendMessage("Ich kann folgendes:");
                    SendMessage("!info");
                    SendMessage("!help");
                    SendMessage("!highscore");
                    SendMessage("!hint");
                    SendMessage("!joke");
                    SendMessage("!quiz");
                    SendMessage("!quote");
                }
                else if(cbMessage=="!quote")
                {
                    Quote quote=Quotes[rnd.Next(Quotes.Count)];
                    SendMessage("\"{0}\" von {1}", quote.QuoteText, quote.Author);
                }
                else if(cbMessage=="!joke")
                {
                    Joke joke=Jokes[rnd.Next(Jokes.Count)];
                    SendMessage(joke.JokeText);
                }

                switch(botMode)
                {
                    case BotMode.Idle:
                        {
                            if(cbMessage=="!quiz")
                            {
                                SendMessage(MultiRandomStrings.QuizStarts);
                                botMode=BotMode.Quiz;

                                Quiz.Start(10, "");
                            }

                            break;
                        }
                    case BotMode.Quiz:
                        {
                            if(cbMessage=="!hint")
                            {
                                SendMessage(Quiz.GetCurrentHint());
                            }

                            bool answerIsCorrect=Quiz.CheckMessageToAnswers(cbMessage);

                            if(answerIsCorrect)
                            {
                                highscore.AddPoints(e.Data.Nick, Quiz.CurrentQuestion.Points);
                                SendMessage(Quiz.GetCurrentSuccess());
                                SendMessage("{0} hat die Frage richtig beantwortet und erhält {1} Punkt(e).", e.Data.Nick, Quiz.CurrentQuestion.Points);

                                Thread.Sleep(800);

                                if(Quiz.SetCurrentQuestionAnswered())
                                {
                                    //Spiel zuende
                                    botMode=BotMode.Idle;

                                    SendMessage(MultiRandomStrings.QuizEnds);
                                }
                            }

                            break;
                        }
                }

            }
            catch(Exception ex)
            {
                string msg=String.Format("[{0:D2}:{1:D2}] {2}: {3}", DateTime.Now.Hour, DateTime.Now.Minute, e.Data.Nick, ex.Message.ToString());
                Console.WriteLine(msg);
            }
        }
Beispiel #2
0
        void OnChannelMessage(object sender, IrcEventArgs e)
        {
            try
            {
                string cbMessage="";

                foreach(string i in e.Data.MessageArray)
                {
                    cbMessage+=i+" ";
                }

                cbMessage=cbMessage.TrimEnd(' ');
                string msg=String.Format("[{0:D2}:{1:D2}] {2}: {3}", DateTime.Now.Hour, DateTime.Now.Minute, e.Data.Nick, cbMessage);
                Conversion.Add(msg);
                Console.WriteLine(msg);
            }
            catch(Exception ex)
            {
                string msg=String.Format("[{0:D2}:{1:D2}] {2}: {3}", DateTime.Now.Hour, DateTime.Now.Minute, e.Data.Nick, ex.Message.ToString());
                Conversion.Add(msg);
                Console.WriteLine(msg);
            }
        }