Example #1
0
        /// <summary>
        /// Deletes the ban.
        /// </summary>
        /// <param name="c">The command argument information.</param>
        /// <returns><c>true</c> if the ban deletion was successful, otherwise <c>false</c>.</returns>
        private async Task <bool> DelBan(Cmd c)
        {
            try
            {
                _banDb.DeleteUserFromDb(Helpers.GetArgVal(c, 2));

                // Unban immediately from QL's internal ban system
                await _sst.QlCommands.CmdUnban(Helpers.GetArgVal(c, 2));

                StatusMessage = string.Format("^2[SUCCESS]^7 Removed time-ban for player^2 {0}",
                                              Helpers.GetArgVal(c, 2));

                await SendServerSay(c, StatusMessage);

                // UI: reflect changes
                _sst.UserInterface.RefreshCurrentBansDataSource();

                return(true);
            }
            catch (Exception e)
            {
                Log.WriteCritical(string.Format(
                                      "Problem encountered while trying to delete user {0} from ban database: {1}",
                                      Helpers.GetArgVal(c, 2),
                                      e.Message), _logClassType, _logPrefix);
            }

            StatusMessage = string.Format(
                "^1[ERROR]^3 An error occurred while attempting to remove time ban for player: ^1{0}",
                Helpers.GetArgVal(c, 2));

            await SendServerTell(c, StatusMessage);

            return(false);
        }
Example #2
0
        /// <summary>
        /// Removes a user's ban and removes/resets any other extraneous ban-related database
        /// properties for the user.
        /// </summary>
        /// <param name="banInfo">The ban information.</param>
        /// <param name="updateUi">
        /// if set to <c>true</c> then update relevant datasources in the user interface.
        /// </param>
        /// <returns><c>true</c> if the ban was deleted, otherwise <c>false</c>.</returns>
        /// <remarks>
        /// This method is typically used when access to the user interface is needed and when the
        /// unban command needs to be directly sent to the game. The underlying SST database classes
        /// are not given access to the main SST class.
        /// </remarks>
        public async Task <bool> RemoveBan(BanInfo banInfo, bool updateUi = true)
        {
            if (banInfo == null)
            {
                return(false);
            }
            // If the user was banned for quitting early, then also remove the user from the early
            // quit database when we clear the expired ban
            if (banInfo.BanType == BanType.AddedByEarlyQuit)
            {
                var eQuitDb = new DbQuits();
                eQuitDb.DeleteUserFromDb(banInfo.PlayerName);

                // UI: reflect changes
                if (updateUi)
                {
                    _sst.UserInterface.RefreshCurrentQuittersDataSource();
                }
            }
            // If the user was banned for using too many substitutes in pickup games, reset the
            // sub-used count
            if (banInfo.BanType == BanType.AddedByPickupSubs)
            {
                var pickupDb = new DbPickups();
                pickupDb.ResetSubsUsedCount(banInfo.PlayerName);
            }
            // If the user was banned for too many no-shows in pickup games, reset the user's
            // no-show count
            if (banInfo.BanType == BanType.AddedByPickupNoShows)
            {
                var pickupDb = new DbPickups();
                pickupDb.ResetNoShowCount(banInfo.PlayerName);
            }
            // Remove the ban from the database. This "on-demand" method of removing the ban is
            // preferred instead of using some mechanism such as a timer that would check every X
            // time period; In other words, leave the user banned until he tries to reconnect then
            // silently remove the ban.
            // Note: expired bans are also removed at various points during the bot's existence, for example,
            // they are also removed when admins try to add, list, or check bans with the timeban
            // command or can be removed using the UI.
            _banDb.DeleteUserFromDb(banInfo.PlayerName);

            // remove from QL's external temp kickban system as well
            if (_sst.IsMonitoringServer)
            {
                await _sst.QlCommands.CmdUnban(banInfo.PlayerName);
            }

            // UI: reflect changes
            if (updateUi)
            {
                _sst.UserInterface.RefreshCurrentBansDataSource();
            }

            return(true);
        }