Exemple #1
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)
        {
            if (Helpers.KeyExists(Helpers.GetArgVal(c, 1), _sst.ServerInfo.CurrentPlayers))
            {
                StatusMessage = string.Format(
                    "^5[LAST SEEN]^7 {0} is here ^5right now!",
                    Helpers.GetArgVal(c, 1));
                await SendServerSay(c, StatusMessage);

                return(true);
            }
            var date = _seenDb.GetLastSeenDate(Helpers.GetArgVal(c, 1));

            if (date != default(DateTime))
            {
                var daysAgo = Math.Truncate((DateTime.Now - date).TotalDays * 100) / 100;
                StatusMessage = string.Format(
                    "^5[LAST SEEN]^7 {0} was last seen on my server at:^5 {1}^7 (^3{2}^7 days ago)",
                    Helpers.GetArgVal(c, 1), date.ToString("g", CultureInfo.CreateSpecificCulture("en-us")), daysAgo);
                await SendServerSay(c, StatusMessage);
            }
            else
            {
                StatusMessage = string.Format(
                    "^5[LAST SEEN]^7 {0} has never been seen on my server.",
                    Helpers.GetArgVal(c, 1));
                await SendServerSay(c, StatusMessage);
            }
            return(true);
        }