From 91a96990aacaeb9a4b4a8e5da4db416646cb6949 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Thu, 22 Sep 2016 19:27:16 +0200 Subject: [PATCH] Add !redeem^ --- ArchiSteamFarm/Bot.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 8e2dabf04..9d07084c4 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -408,7 +408,7 @@ namespace ArchiSteamFarm { return null; } - return await ResponseRedeem(steamID, message, true).ConfigureAwait(false); + return await ResponseRedeem(steamID, message, true, false).ConfigureAwait(false); } if (message.IndexOf(' ') < 0) { @@ -494,10 +494,16 @@ namespace ArchiSteamFarm { return await ResponsePlay(steamID, BotName, args[1]).ConfigureAwait(false); case "!REDEEM": if (args.Length > 2) { - return await ResponseRedeem(steamID, args[1], args[2], false).ConfigureAwait(false); + return await ResponseRedeem(steamID, args[1], args[2], false, false).ConfigureAwait(false); } - return await ResponseRedeem(steamID, BotName, args[1], false).ConfigureAwait(false); + return await ResponseRedeem(steamID, BotName, args[1], false, false).ConfigureAwait(false); + case "!REDEEM^": + if (args.Length > 2) { + return await ResponseRedeem(steamID, args[1], args[2], false, true).ConfigureAwait(false); + } + + return await ResponseRedeem(steamID, BotName, args[1], false, true).ConfigureAwait(false); case "!RESUME": return await ResponsePause(steamID, args[1], false).ConfigureAwait(false); case "!START": @@ -1017,7 +1023,7 @@ namespace ArchiSteamFarm { return "https://github.com/" + SharedInfo.GithubRepo + "/wiki/Commands"; } - private async Task ResponseRedeem(ulong steamID, string message, bool validate) { + private async Task ResponseRedeem(ulong steamID, string message, bool validate, bool skipForwarding) { if ((steamID == 0) || string.IsNullOrEmpty(message)) { Logging.LogNullError(nameof(steamID) + " || " + nameof(message), BotName); return null; @@ -1067,7 +1073,7 @@ namespace ArchiSteamFarm { case ArchiHandler.PurchaseResponseCallback.EPurchaseResult.RegionLocked: response.Append(Environment.NewLine + "<" + currentBot.BotName + "> Key: " + key + " | Status: " + result.PurchaseResult + " | Items: " + string.Join("", result.Items)); - if (!BotConfig.ForwardKeysToOtherBots) { + if (skipForwarding || !BotConfig.ForwardKeysToOtherBots) { key = reader.ReadLine(); // Next key break; // Next bot (if needed) } @@ -1109,7 +1115,7 @@ namespace ArchiSteamFarm { } } - if (!BotConfig.DistributeKeys) { + if (skipForwarding || !BotConfig.DistributeKeys) { continue; } @@ -1122,7 +1128,7 @@ namespace ArchiSteamFarm { return response.Length == 0 ? null : response.ToString(); } - private static async Task ResponseRedeem(ulong steamID, string botName, string message, bool validate) { + private static async Task ResponseRedeem(ulong steamID, string botName, string message, bool validate, bool skipForwarding) { if ((steamID == 0) || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(message)) { Logging.LogNullError(nameof(steamID) + " || " + nameof(botName) + " || " + nameof(message)); return null; @@ -1130,7 +1136,7 @@ namespace ArchiSteamFarm { Bot bot; if (Bots.TryGetValue(botName, out bot)) { - return await bot.ResponseRedeem(steamID, message, validate).ConfigureAwait(false); + return await bot.ResponseRedeem(steamID, message, validate, skipForwarding).ConfigureAwait(false); } if (IsOwner(steamID)) {