Exemplo n.º 1
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#ban" ||
                CommandArray[0].ToLower() == "#unban" ||
                CommandArray[0].ToLower() == "#banguild" ||
                CommandArray[0].ToLower() == "#bg" ||
                CommandArray[0].ToLower() == "#unbanguild" ||
                CommandArray[0].ToLower() == "#ug" ||
                CommandArray[0].ToLower() == "#prefer" ||
                CommandArray[0].ToLower() == "#preferguild" ||
                CommandArray[0].ToLower() == "#pg" ||
                CommandArray[0].ToLower() == "#rank"
                )
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#ban", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank(CommandArray[0], Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                if (CommandArray[0].ToLower() == "#rank")
                {
                    if (CommandArray.Length != 3)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "The " + CommandArray[0].ToLower() + " command requires two parameters, the name and the rank."));
                        return;
                    }
                    TheMySqlManager.UpdatePlayer(CommandArray[1].ToLower(), int.Parse(CommandArray[2]), e.username);
                    return;
                }
                else if (CommandArray.Length != 2)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "The " + CommandArray[0].ToLower() + " command requires one parameter, the name."));
                    return;
                }
                string name = CommandArray[1];
                if (CommandArray[0] == "#ban")
                {
                    TheMySqlManager.UpdatePlayer(name.ToLower(), -1, e.username);
                }
                else if (CommandArray[0] == "#unban")
                {
                    TheMySqlManager.UpdatePlayer(name.ToLower(), 0, e.username);
                }
                else if (CommandArray[0] == "#prefer")
                {
                    TheMySqlManager.UpdatePlayer(name.ToLower(), 1, e.username);
                }
                else if (CommandArray[0] == "#banguild" || CommandArray[0] == "#bg")
                {
                    TheMySqlManager.BanGuild(CommandArray[1], -1, e.username);
                }
                else if (CommandArray[0] == "#unbanguild" || CommandArray[0] == "#ug")
                {
                    TheMySqlManager.BanGuild(CommandArray[1], 0, e.username);
                }
                else if (CommandArray[0] == "#preferguild" || CommandArray[0] == "#pg")
                {
                    TheMySqlManager.BanGuild(CommandArray[1], 1, e.username);
                }
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Command executed."));
            }

            return;
        }