From 9d97ca16e8d67da7f1fd83e20c45f1eb842c81ff Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sat, 7 May 2016 15:24:09 +0200 Subject: [PATCH] Misc WCF code review --- ArchiSteamFarm/WCF.cs | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/ArchiSteamFarm/WCF.cs b/ArchiSteamFarm/WCF.cs index 1f7b071ba..315a9fe00 100644 --- a/ArchiSteamFarm/WCF.cs +++ b/ArchiSteamFarm/WCF.cs @@ -101,35 +101,18 @@ namespace ArchiSteamFarm { return null; } - string[] args = input.Split(' '); - - string botName; - - if (args.Length > 1) { // If we have args[1] provided, use given botName - botName = args[1]; - } else { // If not, just pick first one - botName = Bot.Bots.Keys.FirstOrDefault(); + Bot bot = Bot.Bots.Values.FirstOrDefault(); + if (bot == null) { + return "ERROR: No bots are enabled!"; } - if (string.IsNullOrEmpty(botName)) { - return "ERROR: Invalid botName: " + botName; - } - - Bot bot; - if (!Bot.Bots.TryGetValue(botName, out bot)) { - return "ERROR: Couldn't find any bot named: " + botName; - } - - Logging.LogGenericInfo("Received command: " + input); - - string output; if (Program.GlobalConfig.SteamOwnerID == 0) { - output = "Refusing to handle request because SteamOwnerID is not set!"; - } else { - string command = '!' + input; - output = bot.Response(Program.GlobalConfig.SteamOwnerID, command).Result; // TODO: This should be asynchronous + return "Refusing to handle request because SteamOwnerID is not set!"; } + string command = "!" + input; + string output = bot.Response(Program.GlobalConfig.SteamOwnerID, command).Result; // TODO: This should be asynchronous + Logging.LogGenericInfo("Answered to command: " + input + " with: " + output); return output; }