コード例 #1
0
        private static async Task <string?> CheckItem(ulong steamID, Bot bot, string appid, string itemdefId)
        {
            if (!bot.HasPermission(steamID, BotConfig.EPermission.Master))
            {
                return(null);
            }

            if (!uint.TryParse(appid, out uint appId))
            {
                return(bot.Commands.FormatBotResponse(string.Format(Strings.ErrorIsInvalid, nameof(appId))));
            }
            if (!uint.TryParse(itemdefId, out uint itemdefid))
            {
                return(bot.Commands.FormatBotResponse(string.Format(Strings.ErrorIsInvalid, nameof(itemdefid))));
            }
            if (!ItemDropHandlers.TryGetValue(bot, out ItemDropHandler? ItemDropHandler))
            {
                return(bot.Commands.FormatBotResponse(string.Format(Strings.ErrorIsEmpty, nameof(ItemDropHandlers))));
            }
            return(bot.Commands.FormatBotResponse(await Task.Run <string>(() => ItemDropHandler.checkTime(appId, itemdefid)).ConfigureAwait(false)));
        }
コード例 #2
0
        private static async Task <string?> CheckItem(ulong steamID, Bot bot, string appid, string itemdefId, bool longoutput)
        {
            if (!bot.HasAccess(steamID, BotConfig.EAccess.Master))
            {
                bot.ArchiLogger.LogGenericError("Bot has no access");
                return(null);
            }
            if (!uint.TryParse(appid, out uint appId))
            {
                return(bot.Commands.FormatBotResponse(string.Format(Strings.ErrorIsInvalid, nameof(appId))));
            }
            if (!uint.TryParse(itemdefId, out uint itemdefid))
            {
                return(bot.Commands.FormatBotResponse(string.Format(Strings.ErrorIsInvalid, nameof(itemdefid))));
            }
            if (!ItemDropHandlers.TryGetValue(bot, out ItemDropHandler? ItemDropHandler))
            {
                return(bot.Commands.FormatBotResponse(string.Format(Strings.ErrorIsEmpty, nameof(ItemDropHandlers))));
            }

            return(bot.Commands.FormatBotResponse(await Task.Run <string>(() => ItemDropHandler.checkTime(appId, itemdefid, bot, longoutput)).ConfigureAwait(false)));
        }