Esempio n. 1
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);
        }
Esempio n. 2
0
        /// <summary>
        /// Clears the early quits for a given user.
        /// </summary>
        /// <param name="c">The command argument information.</param>
        /// <param name="qdb">The quit database.</param>
        private async Task ClearEarlyQuits(Cmd c, DbQuits qdb)
        {
            qdb.DeleteUserFromDb(Helpers.GetArgVal(c, 3));

            StatusMessage = string.Format("^5[EARLYQUIT]^7 Cleared all early quit records for: ^3{0}",
                                          Helpers.GetArgVal(c, 3));
            await SendServerSay(c, StatusMessage);

            // See if there is an early quit-related ban and remove it as well
            await qdb.RemoveQuitRelatedBan(_sst, Helpers.GetArgVal(c, 3));

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