Exemple #1
0
        /// <summary>
        /// Runs the user date check on a given player.
        /// </summary>
        /// <param name="user">The user.</param>
        public async Task RunUserDateCheck(string user)
        {
            var qlDateChecker = new QlAccountDateChecker();
            var date          = await qlDateChecker.GetUserRegistrationDate(user);

            await VerifyUserDate(user, date);
        }
Exemple #2
0
        /// <summary>
        /// Executes the specified command asynchronously.
        /// </summary>
        /// <param name="c">The command argument information.</param>
        /// <returns><c>true</c> if the command was successfully executed, otherwise <c>false</c>.</returns>
        /// <remarks>Helpers.GetArgVal(c, 1) if specified: user to check</remarks>
        public async Task <bool> ExecAsync(Cmd c)
        {
            // DB
            var date = _registrationDb.GetRegistrationDate(Helpers.GetArgVal(c, 1));

            if (date == default(DateTime))
            {
                // Not in DB, so retrieve from QL website
                var qlDateChecker = new QlAccountDateChecker();
                date = await qlDateChecker.GetUserRegistrationDate(Helpers.GetArgVal(c, 1));
            }
            // Display
            if (date == default(DateTime))
            {
                StatusMessage = string.Format(
                    "^1[ERROR]^7 Unable to retrieve {0}'s account registration date.",
                    Helpers.GetArgVal(c, 1));
                await SendServerTell(c, StatusMessage);

                Log.Write(string.Format("Could not retrieve account registration date for player {0}",
                                        Helpers.GetArgVal(c, 1)), _logClassType, _logPrefix);

                return(false);
            }
            var daysAgo = Math.Truncate((DateTime.Now - date).TotalDays * 100) / 100;

            StatusMessage = string.Format(
                "^5[DATE]^7 {0}'s account was registered on:^5 {1}^7 (^3{2} ^7days old)",
                Helpers.GetArgVal(c, 1), date.ToString("d"), daysAgo);
            await SendServerSay(c, StatusMessage);

            return(true);
        }
Exemple #3
0
        /// <summary>
        /// Runs the user date check on all current players.
        /// </summary>
        /// <param name="players">The players.</param>
        public async Task RunUserDateCheck(Dictionary <string, PlayerInfo> players)
        {
            var qlDateChecker = new QlAccountDateChecker();

            foreach (var player in players.ToList())
            {
                var date = await qlDateChecker.GetUserRegistrationDate(player.Key);
                await VerifyUserDate(player.Key, date);
            }
        }