Example #1
0
        /// <summary>
        /// Checks the amount of early quits that a given user has.
        /// </summary>
        /// <param name="c">The command argument information.</param>
        private async Task CheckQuits(Cmd c)
        {
            var totalQuits = _quitDb.GetUserQuitCount(Helpers.GetArgVal(c, 2));
            var qStr       = totalQuits > 0
                ? string.Format("^1 {0} ^7early quits", totalQuits)
                : "^2no^7 early quits";
            var quitsRemaining = (_sst.Mod.EarlyQuit.MaxQuitsAllowed - totalQuits);

            StatusMessage = string.Format(
                "^5[EARLYQUIT] ^3{0}^7 has {1}. ^1 {2} ^7remaining before banned for ^1{3} {4}",
                Helpers.GetArgVal(c, 2), qStr, quitsRemaining, _sst.Mod.EarlyQuit.BanTime,
                _sst.Mod.EarlyQuit.BanTimeScale);
            await SendServerSay(c, StatusMessage);
        }
Example #2
0
        /// <summary>
        /// Evaluates the user quit count and bans the user if count exceeds a certain value.
        /// </summary>
        /// <param name="player">The player.</param>
        private async Task <long> EvaluateUserQuitCount(string player)
        {
            var quitCount = _quitsDb.GetUserQuitCount(player);

            if (quitCount >= _maxQuitsAllowed)
            {
                await BanEarlyQuitter(player);

                Log.Write(string.Format(
                              "Will attempt to add ban for {0} because of too many early quits ({1}, " +
                              "max allowed: {2}) if admin ban doesn't already exist.",
                              player, quitCount, _maxQuitsAllowed), _logClassType, _logPrefix);
            }
            return(quitCount);
        }
Example #3
0
        /// <summary>
        /// Evaluates the early quit forgive command to see if it can be successfully processed.
        /// </summary>
        /// <param name="c">The command argument information.</param>
        /// <returns><c>true</c> if the evaluation was successful, otherwise <c>false</c>.</returns>
        private async Task <bool> EvalEarlyQuitForgive(Cmd c)
        {
            if (c.Args.Length != (c.FromIrc ? 6 : 5))
            {
                StatusMessage = string.Format(
                    "^1[ERROR]^3 Usage: {0}{1} {2} forgive <name> <# of quits> ^7 - name is without the clan" +
                    " tag. # quits is amount to forgive",
                    CommandList.GameCommandPrefix, c.CmdName,
                    ((c.FromIrc)
                        ? (string.Format("{0} {1}", c.Args[1],
                                         NameModule))
                        : NameModule));
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            var quitDb = new DbQuits();

            if (!quitDb.UserExistsInDb(Helpers.GetArgVal(c, 3)))
            {
                StatusMessage = string.Format("^1[ERROR]^7 {0}^3 has no early quits.", Helpers.GetArgVal(c, 3));
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            int numQuitsToForgive;

            if (!int.TryParse(Helpers.GetArgVal(c, 4), out numQuitsToForgive))
            {
                StatusMessage = "^1[ERROR]^3 # of quits must be a number greater than zero!";
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            if (numQuitsToForgive == 0)
            {
                StatusMessage = "^1[ERROR]^3 # of quits must be greater than zero.";
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            var userTotalQuits = quitDb.GetUserQuitCount(Helpers.GetArgVal(c, 3));

            if (numQuitsToForgive >= userTotalQuits)
            {
                StatusMessage =
                    string.Format(
                        "^1[ERROR]^3 {0} has^1 {1}^3 total quits. This would remove all. If that's" +
                        " what you want: ^1{2}{3} {4} clear {0}",
                        Helpers.GetArgVal(c, 3), userTotalQuits,
                        CommandList.GameCommandPrefix, c.CmdName,
                        ((c.FromIrc)
                            ? (string.Format("{0} {1}", c.Args[1],
                                             NameModule))
                            : NameModule));
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            await ForgiveEarlyQuits(c, numQuitsToForgive, Helpers.GetArgVal(c, 3), quitDb);

            return(true);
        }