SendPrivateMessage() private method

private SendPrivateMessage ( IEnumerable targetsNames, string text ) : void
targetsNames IEnumerable
text string
return void
コード例 #1
0
        private void HandleEventLoop(IrcDotNet.IrcClient client)
        {
            logger.Debug("In HandleEventLoop");

            IsExit = false;
            while (!IsExit)
            {
                Console.Write("> ");
                var command = Console.ReadLine();
                switch (command)
                {
                case "exit":
                case "quit":
                    IsExit = true;
                    break;

                default:
                    if (!string.IsNullOrEmpty(command))
                    {
                        if (command.StartsWith("limit"))
                        {
                            short tempLimit;
                            if (Int16.TryParse(command.Substring(6).Trim(), out tempLimit))
                            {
                                levels.LevelLimit = tempLimit;
                            }
                        }

                        else if (command == "o")
                        {
                            if (!levels.Open)
                            {
                                levels.OpenQueue();
                                client.SendPrivateMessage(MAINCHANNEL, "/me Submissions Open");
                                client.SendPrivateMessage(MAINCHANNEL, "/me Submit levels with !submit");
                            }
                        }

                        else if (command == "c")
                        {
                            if (levels.Open)
                            {
                                levels.CloseQueue();
                                client.SendPrivateMessage(MAINCHANNEL, "/me Submissions Closed");
                                if (levels.FinalLevels.Count >= 0)
                                {
                                    string plural = (levels.FinalLevels.Count != 1) ? " levels " : " level ";
                                    client.SendPrivateMessage(MAINCHANNEL, "/me " + levels.FinalLevels.Count + plural + "will be randomly picked.");
                                    client.SendPrivateMessage(MAINCHANNEL, "/me Now Playing: " + levels.CurrentLevel);
                                    Console.WriteLine();
                                    Console.WriteLine(levels.CurrentLevel + " (" + levels.Remaining + ")");
                                    Console.WriteLine();
                                    PostToWebsite();
                                }
                                else
                                {
                                    client.SendPrivateMessage(MAINCHANNEL, "/me No Levels submitted.");
                                }
                            }
                        }

                        else if (command.StartsWith("s "))
                        {
                            command = command.Remove(0, 2).Trim();
                            SaveLevel(command);
                        }

                        else if (command == "settings")
                        {
                            OpenSettingsWindow();
                        }

                        else if (command == "restart")
                        {
                            this.Restart = true;
                            return;
                        }

                        else if (command.StartsWith("v "))
                        {
                            command = command.Remove(0, 2).Trim();
                            short vol;
                            if (Int16.TryParse(command, out vol))
                            {
                                soundPlayerVolume = vol;
                            }
                        }

                        else if (command.StartsWith("max "))
                        {
                            command = command.Remove(0, 4).Trim();
                            int amt;
                            if (Int32.TryParse(command, out amt))
                            {
                                if (amt <= 0)
                                {
                                    break;
                                }
                                BotSettings.MaxSubmissionsForSingleUser = amt;
                                Console.WriteLine("User can only submit " + amt + " level(s) per round.");
                                Console.WriteLine();
                            }
                        }

                        else if (command.StartsWith("cool "))
                        {
                            command = command.Remove(0, 5).Trim();
                            int tempCooldown;
                            if (int.TryParse(command, out tempCooldown))
                            {
                                cooldownSeconds = tempCooldown;
                            }
                        }

                        else if (command == "q")
                        {
                            foreach (var level in levels.FinalLevels)
                            {
                                Console.WriteLine(level.Item2 + " " + level.Item1);
                            }
                        }


                        else if (command.StartsWith("add "))
                        {
                            string[] args = command.Split(' ');
                            if (args.Length > 2)
                            {
                                if (LevelSubmitter.IsValidLevelCode(ref args[2]))
                                {
                                    levels.ForceAddLevel(args[2].ToUpper(), args[1]);
                                    PostToWebsite();
                                    if (levels.Remaining == 0)
                                    {
                                        Console.WriteLine(levels.CurrentLevel + " (" + levels.Remaining + ")");
                                    }
                                }
                            }
                        }

                        else if (command == "prev")
                        {
                            if (levels.Remaining == levels.FinalLevels.Count)
                            {
                                break;
                            }
                            levels.PreviousLevel();
                            PostToWebsite();
                            Console.WriteLine();
                            Console.WriteLine(levels.CurrentLevel + " (" + levels.Remaining + ")");
                            Console.WriteLine();
                        }

                        else if (command == "h" || command == "help")
                        {
                            DisplayMainMenu();
                        }
                    }

                    //ELSE - command IsNullOrEmpty - (Enter Key pressed)
                    else
                    {
                        if (levels.Remaining > 0)
                        {
                            levels.NextLevel();
                            PostToWebsite();
                            client.SendPrivateMessage(MAINCHANNEL, "/me Now Playing: " + levels.CurrentLevel);
                            Console.WriteLine();
                            Console.WriteLine(levels.CurrentLevel + " (" + levels.Remaining + ")");
                            Console.WriteLine();
                        }
                    }

                    break;
                }
            }

            client.Disconnect();
        }