From 0ddcf004c14e8d4fd70b909a1eb465a3384947fb Mon Sep 17 00:00:00 2001 From: Ryzhehvost Date: Sun, 10 Jan 2016 18:34:30 +0200 Subject: [PATCH 1/4] command !status all to bring them all --- ArchiSteamFarm/Bot.cs | 23 ++++++++++++++++++++--- ArchiSteamFarm/WCF.cs | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 2c00b630f..1894b8be8 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -439,16 +439,33 @@ namespace ArchiSteamFarm { } internal static string ResponseStatus(string botName) { + Bot bot; + string result=""; if (string.IsNullOrEmpty(botName)) { return null; + } else { + if (botName.Equals("all")) { + foreach (var curbot in Bots) { + if (curbot.Value.CardsFarmer.CurrentGamesFarming.Count == 0) + result+="Bot " + curbot.Key + " is not farming.\n"; + else + result+="Bot " + curbot.Key + " is currently farming appIDs: " + string.Join(", ", curbot.Value.CardsFarmer.CurrentGamesFarming) + " and has a total of " + curbot.Value.CardsFarmer.GamesToFarm.Count + " games left to farm.\n"; + } + result+="Currently " + Bots.Count + " bots are running."; + return result; } - Bot bot; if (!Bots.TryGetValue(botName, out bot)) { - return "Couldn't find any bot named " + botName + "!"; + result+="Couldn't find any bot named " + botName + "!"; + return result; + } } - return "Bot " + bot.BotName + " is currently farming appIDs: " + string.Join(", ", bot.CardsFarmer.CurrentGamesFarming) + " and has a total of " + bot.CardsFarmer.GamesToFarm.Count + " games left to farm"; + if (bot.CardsFarmer.CurrentGamesFarming.Count > 0) { + result+="Bot " + bot.BotName + " is currently farming appIDs: " + string.Join(", ", bot.CardsFarmer.CurrentGamesFarming) + " and has a total of " + bot.CardsFarmer.GamesToFarm.Count + " games left to farm.\n"; + } + result+="Currently " + Bots.Count + " bots are running"; + return result; } internal static string Response2FA(string botName) { diff --git a/ArchiSteamFarm/WCF.cs b/ArchiSteamFarm/WCF.cs index ea83a8ca9..1468f6e81 100644 --- a/ArchiSteamFarm/WCF.cs +++ b/ArchiSteamFarm/WCF.cs @@ -84,6 +84,7 @@ namespace ArchiSteamFarm { Logging.LogGenericInfo("WCF", "Received command: \"" + input + "\""); string command = '!' + input; + if (command.Equals("!status")) command+=" all"; //show status off all bots if no bot specified string output = bot.HandleMessage(command).Result; // TODO: This should be asynchronous Logging.LogGenericInfo("WCF", "Answered to command: \"" + input + "\" with: \"" + output + "\""); From 5b711f158d8e5a5ab36d6bec9a56e738bc14d7b6 Mon Sep 17 00:00:00 2001 From: Ryzhehvost Date: Sun, 10 Jan 2016 18:50:17 +0200 Subject: [PATCH 2/4] remove excessive else --- ArchiSteamFarm/Bot.cs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 1894b8be8..2b9a421ac 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -443,24 +443,23 @@ namespace ArchiSteamFarm { string result=""; if (string.IsNullOrEmpty(botName)) { return null; - } else { - if (botName.Equals("all")) { - foreach (var curbot in Bots) { - if (curbot.Value.CardsFarmer.CurrentGamesFarming.Count == 0) - result+="Bot " + curbot.Key + " is not farming.\n"; - else - result+="Bot " + curbot.Key + " is currently farming appIDs: " + string.Join(", ", curbot.Value.CardsFarmer.CurrentGamesFarming) + " and has a total of " + curbot.Value.CardsFarmer.GamesToFarm.Count + " games left to farm.\n"; - } - result+="Currently " + Bots.Count + " bots are running."; - return result; + } + if (botName.Equals("all")) { + foreach (var curbot in Bots) { + if (curbot.Value.CardsFarmer.CurrentGamesFarming.Count == 0) + result+="Bot " + curbot.Key + " is not farming.\n"; + else + result+="Bot " + curbot.Key + " is currently farming appIDs: " + string.Join(", ", curbot.Value.CardsFarmer.CurrentGamesFarming) + " and has a total of " + curbot.Value.CardsFarmer.GamesToFarm.Count + " games left to farm.\n"; + } + result+="Currently " + Bots.Count + " bots are running."; + return result; } if (!Bots.TryGetValue(botName, out bot)) { result+="Couldn't find any bot named " + botName + "!"; return result; - } } - + if (bot.CardsFarmer.CurrentGamesFarming.Count > 0) { result+="Bot " + bot.BotName + " is currently farming appIDs: " + string.Join(", ", bot.CardsFarmer.CurrentGamesFarming) + " and has a total of " + bot.CardsFarmer.GamesToFarm.Count + " games left to farm.\n"; } From 08a962e688611dfa2511716a38362b4fb47e910b Mon Sep 17 00:00:00 2001 From: Ryzhehvost Date: Sun, 10 Jan 2016 19:39:12 +0200 Subject: [PATCH 3/4] statusall --- ArchiSteamFarm/Bot.cs | 28 ++++++++++++++++------------ ArchiSteamFarm/WCF.cs | 1 - 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 2b9a421ac..165fe6180 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -444,20 +444,10 @@ namespace ArchiSteamFarm { if (string.IsNullOrEmpty(botName)) { return null; } - if (botName.Equals("all")) { - foreach (var curbot in Bots) { - if (curbot.Value.CardsFarmer.CurrentGamesFarming.Count == 0) - result+="Bot " + curbot.Key + " is not farming.\n"; - else - result+="Bot " + curbot.Key + " is currently farming appIDs: " + string.Join(", ", curbot.Value.CardsFarmer.CurrentGamesFarming) + " and has a total of " + curbot.Value.CardsFarmer.GamesToFarm.Count + " games left to farm.\n"; - } - result+="Currently " + Bots.Count + " bots are running."; - return result; - } if (!Bots.TryGetValue(botName, out bot)) { - result+="Couldn't find any bot named " + botName + "!"; - return result; + result+="Couldn't find any bot named " + botName + "!"; + return result; } if (bot.CardsFarmer.CurrentGamesFarming.Count > 0) { @@ -467,6 +457,18 @@ namespace ArchiSteamFarm { return result; } + internal static string ResponseStatusAll() { + string result = ""; + foreach (var curbot in Bots) { + if (curbot.Value.CardsFarmer.CurrentGamesFarming.Count == 0) + result += "Bot " + curbot.Key + " is not farming.\n"; + else + result += "Bot " + curbot.Key + " is currently farming appIDs: " + string.Join(", ", curbot.Value.CardsFarmer.CurrentGamesFarming) + " and has a total of " + curbot.Value.CardsFarmer.GamesToFarm.Count + " games left to farm.\n"; + } + result += "Currently " + Bots.Count + " bots are running."; + return result; + } + internal static string Response2FA(string botName) { if (string.IsNullOrEmpty(botName)) { return null; @@ -591,6 +593,8 @@ namespace ArchiSteamFarm { return "Done"; case "!status": return ResponseStatus(BotName); + case "!statusall": + return ResponseStatusAll(); case "!stop": return await ResponseStop(BotName).ConfigureAwait(false); default: diff --git a/ArchiSteamFarm/WCF.cs b/ArchiSteamFarm/WCF.cs index 1468f6e81..ea83a8ca9 100644 --- a/ArchiSteamFarm/WCF.cs +++ b/ArchiSteamFarm/WCF.cs @@ -84,7 +84,6 @@ namespace ArchiSteamFarm { Logging.LogGenericInfo("WCF", "Received command: \"" + input + "\""); string command = '!' + input; - if (command.Equals("!status")) command+=" all"; //show status off all bots if no bot specified string output = bot.HandleMessage(command).Result; // TODO: This should be asynchronous Logging.LogGenericInfo("WCF", "Answered to command: \"" + input + "\" with: \"" + output + "\""); From 67f0b0f8e9019bcc1e682ce56eac41ffd7af6124 Mon Sep 17 00:00:00 2001 From: Ryzhehvost Date: Sun, 10 Jan 2016 20:22:46 +0200 Subject: [PATCH 4/4] cleanup --- ArchiSteamFarm/Bot.cs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 165fe6180..abf215a56 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -33,6 +33,7 @@ using System.IO; using System.Security.Cryptography; using System.Threading.Tasks; using System.Xml; +using System.Text; namespace ArchiSteamFarm { internal sealed class Bot { @@ -440,33 +441,29 @@ namespace ArchiSteamFarm { internal static string ResponseStatus(string botName) { Bot bot; - string result=""; if (string.IsNullOrEmpty(botName)) { return null; } if (!Bots.TryGetValue(botName, out bot)) { - result+="Couldn't find any bot named " + botName + "!"; - return result; + return "Couldn't find any bot named " + botName + "!"; ; } if (bot.CardsFarmer.CurrentGamesFarming.Count > 0) { - result+="Bot " + bot.BotName + " is currently farming appIDs: " + string.Join(", ", bot.CardsFarmer.CurrentGamesFarming) + " and has a total of " + bot.CardsFarmer.GamesToFarm.Count + " games left to farm.\n"; + return "Bot " + bot.BotName + " is currently farming appIDs: " + string.Join(", ", bot.CardsFarmer.CurrentGamesFarming) + " and has a total of " + bot.CardsFarmer.GamesToFarm.Count + " games left to farm."; + } else { + return "Bot " + bot.BotName + " is not farming."; + } - result+="Currently " + Bots.Count + " bots are running"; - return result; } internal static string ResponseStatusAll() { - string result = ""; + StringBuilder result = new StringBuilder(); foreach (var curbot in Bots) { - if (curbot.Value.CardsFarmer.CurrentGamesFarming.Count == 0) - result += "Bot " + curbot.Key + " is not farming.\n"; - else - result += "Bot " + curbot.Key + " is currently farming appIDs: " + string.Join(", ", curbot.Value.CardsFarmer.CurrentGamesFarming) + " and has a total of " + curbot.Value.CardsFarmer.GamesToFarm.Count + " games left to farm.\n"; + result.Append(ResponseStatus(curbot.Key)+Environment.NewLine); } - result += "Currently " + Bots.Count + " bots are running."; - return result; + result.Append("Currently " + Bots.Count + " bots are running."); + return result.ToString(); } internal static string Response2FA(string botName) {