From fc4574d143e7004d088788ad629534bd236287d2 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Tue, 31 Jan 2017 01:10:01 +0100 Subject: [PATCH] Closes #445 Review https://github.com/JustArchi/ArchiSteamFarm/wiki/Logging for examples once I'm done updating the wiki --- ArchiSteamFarm/ASF.cs | 62 ++++++------ ArchiSteamFarm/ArchiHandler.cs | 8 +- ArchiSteamFarm/ArchiSteamFarm.csproj | 1 + ArchiSteamFarm/ArchiWebHandler.cs | 14 +-- ArchiSteamFarm/Bot.cs | 99 ++++++++++--------- ArchiSteamFarm/BotConfig.cs | 8 +- ArchiSteamFarm/BotDatabase.cs | 10 +- .../CMsgs/CMsgClientClanInviteAction.cs | 4 +- ArchiSteamFarm/CryptoHelper.cs | 22 ++--- ArchiSteamFarm/Debugging.cs | 4 +- ArchiSteamFarm/Events.cs | 2 +- ArchiSteamFarm/GlobalConfig.cs | 16 +-- ArchiSteamFarm/GlobalDatabase.cs | 10 +- ArchiSteamFarm/InMemoryServerListProvider.cs | 2 +- ArchiSteamFarm/JSON/Steam.cs | 38 +++---- ArchiSteamFarm/Logging.cs | 2 +- ArchiSteamFarm/Program.cs | 53 +++++----- ArchiSteamFarm/Runtime.cs | 36 +++---- ArchiSteamFarm/Statistics.cs | 2 +- ArchiSteamFarm/SteamTarget.cs | 82 +++++++++++++++ ArchiSteamFarm/Utilities.cs | 8 +- ArchiSteamFarm/WCF.cs | 22 ++--- GUI/GUI.csproj | 3 + 23 files changed, 305 insertions(+), 203 deletions(-) create mode 100644 ArchiSteamFarm/SteamTarget.cs diff --git a/ArchiSteamFarm/ASF.cs b/ArchiSteamFarm/ASF.cs index 7b5eb9805..c6c6927fa 100644 --- a/ArchiSteamFarm/ASF.cs +++ b/ArchiSteamFarm/ASF.cs @@ -37,6 +37,8 @@ namespace ArchiSteamFarm { internal static class ASF { private const byte AutoUpdatePeriodInHours = 24; + internal static readonly ArchiLogger ArchiLogger = new ArchiLogger(SharedInfo.ASF); + private static readonly ConcurrentDictionary LastWriteTimes = new ConcurrentDictionary(); private static Timer AutoUpdatesTimer; @@ -45,7 +47,7 @@ namespace ArchiSteamFarm { internal static async Task CheckForUpdate(bool updateOverride = false) { string exeFile = Assembly.GetEntryAssembly().Location; if (string.IsNullOrEmpty(exeFile)) { - Program.ArchiLogger.LogNullError(nameof(exeFile)); + ArchiLogger.LogNullError(nameof(exeFile)); return; } @@ -59,8 +61,8 @@ namespace ArchiSteamFarm { try { File.Delete(oldExeFile); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); - Program.ArchiLogger.LogGenericError(string.Format(Strings.ErrorRemovingOldBinary, oldExeFile)); + ArchiLogger.LogGenericException(e); + ArchiLogger.LogGenericError(string.Format(Strings.ErrorRemovingOldBinary, oldExeFile)); } } @@ -76,7 +78,7 @@ namespace ArchiSteamFarm { TimeSpan.FromHours(AutoUpdatePeriodInHours) // Period ); - Program.ArchiLogger.LogGenericInfo(string.Format(Strings.AutoUpdateCheckInfo, AutoUpdatePeriodInHours)); + ArchiLogger.LogGenericInfo(string.Format(Strings.AutoUpdateCheckInfo, AutoUpdatePeriodInHours)); } string releaseURL = SharedInfo.GithubReleaseURL; @@ -84,20 +86,20 @@ namespace ArchiSteamFarm { releaseURL += "/latest"; } - Program.ArchiLogger.LogGenericInfo(Strings.UpdateCheckingNewVersion); + ArchiLogger.LogGenericInfo(Strings.UpdateCheckingNewVersion); GitHub.ReleaseResponse releaseResponse; if (Program.GlobalConfig.UpdateChannel == GlobalConfig.EUpdateChannel.Stable) { releaseResponse = await Program.WebBrowser.UrlGetToJsonResultRetry(releaseURL).ConfigureAwait(false); if (releaseResponse == null) { - Program.ArchiLogger.LogGenericWarning(Strings.ErrorUpdateCheckFailed); + ArchiLogger.LogGenericWarning(Strings.ErrorUpdateCheckFailed); return; } } else { List releases = await Program.WebBrowser.UrlGetToJsonResultRetry>(releaseURL).ConfigureAwait(false); if ((releases == null) || (releases.Count == 0)) { - Program.ArchiLogger.LogGenericWarning(Strings.ErrorUpdateCheckFailed); + ArchiLogger.LogGenericWarning(Strings.ErrorUpdateCheckFailed); return; } @@ -105,32 +107,32 @@ namespace ArchiSteamFarm { } if (string.IsNullOrEmpty(releaseResponse.Tag)) { - Program.ArchiLogger.LogGenericWarning(Strings.ErrorUpdateCheckFailed); + ArchiLogger.LogGenericWarning(Strings.ErrorUpdateCheckFailed); return; } Version newVersion = new Version(releaseResponse.Tag); - Program.ArchiLogger.LogGenericInfo(string.Format(Strings.UpdateVersionInfo, SharedInfo.Version, newVersion)); + ArchiLogger.LogGenericInfo(string.Format(Strings.UpdateVersionInfo, SharedInfo.Version, newVersion)); if (SharedInfo.Version.CompareTo(newVersion) >= 0) { // If local version is the same or newer than remote version return; } if (!updateOverride && !Program.GlobalConfig.AutoUpdates) { - Program.ArchiLogger.LogGenericInfo(Strings.UpdateNewVersionAvailable); + ArchiLogger.LogGenericInfo(Strings.UpdateNewVersionAvailable); await Task.Delay(5000).ConfigureAwait(false); return; } if (File.Exists(oldExeFile)) { - Program.ArchiLogger.LogGenericError(string.Format(Strings.ErrorRemovingOldBinary, oldExeFile)); + ArchiLogger.LogGenericError(string.Format(Strings.ErrorRemovingOldBinary, oldExeFile)); return; } // Auto update logic starts here if (releaseResponse.Assets == null) { - Program.ArchiLogger.LogGenericWarning(Strings.ErrorUpdateNoAssets); + ArchiLogger.LogGenericWarning(Strings.ErrorUpdateNoAssets); return; } @@ -138,16 +140,16 @@ namespace ArchiSteamFarm { GitHub.ReleaseResponse.Asset binaryAsset = releaseResponse.Assets.FirstOrDefault(asset => !string.IsNullOrEmpty(asset.Name) && asset.Name.Equals(exeFileName, StringComparison.OrdinalIgnoreCase)); if (binaryAsset == null) { - Program.ArchiLogger.LogGenericWarning(Strings.ErrorUpdateNoAssetForThisBinary); + ArchiLogger.LogGenericWarning(Strings.ErrorUpdateNoAssetForThisBinary); return; } if (string.IsNullOrEmpty(binaryAsset.DownloadURL)) { - Program.ArchiLogger.LogNullError(nameof(binaryAsset.DownloadURL)); + ArchiLogger.LogNullError(nameof(binaryAsset.DownloadURL)); return; } - Program.ArchiLogger.LogGenericInfo(Strings.UpdateDownloadingNewVersion); + ArchiLogger.LogGenericInfo(Strings.UpdateDownloadingNewVersion); byte[] result = await Program.WebBrowser.UrlGetToBytesRetry(binaryAsset.DownloadURL).ConfigureAwait(false); if (result == null) { @@ -160,7 +162,7 @@ namespace ArchiSteamFarm { try { File.WriteAllBytes(newExeFile, result); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ArchiLogger.LogGenericException(e); return; } @@ -168,7 +170,7 @@ namespace ArchiSteamFarm { try { File.Move(exeFile, oldExeFile); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ArchiLogger.LogGenericException(e); try { // Cleanup File.Delete(newExeFile); @@ -182,7 +184,7 @@ namespace ArchiSteamFarm { try { File.Move(newExeFile, exeFile); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ArchiLogger.LogGenericException(e); try { // Cleanup File.Move(oldExeFile, exeFile); @@ -193,7 +195,7 @@ namespace ArchiSteamFarm { return; } - Program.ArchiLogger.LogGenericInfo(Strings.UpdateFinished); + ArchiLogger.LogGenericInfo(Strings.UpdateFinished); await RestartOrExit().ConfigureAwait(false); } @@ -217,7 +219,7 @@ namespace ArchiSteamFarm { } if (Bot.Bots.Count == 0) { - Program.ArchiLogger.LogGenericWarning(Strings.ErrorNoBotsDefined); + ArchiLogger.LogGenericWarning(Strings.ErrorNoBotsDefined); } } @@ -240,7 +242,7 @@ namespace ArchiSteamFarm { private static async Task CreateBot(string botName) { if (string.IsNullOrEmpty(botName)) { - Program.ArchiLogger.LogNullError(nameof(botName)); + ArchiLogger.LogNullError(nameof(botName)); return; } @@ -260,7 +262,7 @@ namespace ArchiSteamFarm { private static async void OnChanged(object sender, FileSystemEventArgs e) { if ((sender == null) || (e == null)) { - Program.ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); + ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); return; } @@ -270,7 +272,7 @@ namespace ArchiSteamFarm { } if (botName.Equals(SharedInfo.ASF)) { - Program.ArchiLogger.LogGenericInfo(Strings.GlobalConfigChanged); + ArchiLogger.LogGenericInfo(Strings.GlobalConfigChanged); await RestartOrExit().ConfigureAwait(false); return; } @@ -312,7 +314,7 @@ namespace ArchiSteamFarm { private static void OnCreated(object sender, FileSystemEventArgs e) { if ((sender == null) || (e == null)) { - Program.ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); + ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); return; } @@ -326,7 +328,7 @@ namespace ArchiSteamFarm { private static void OnDeleted(object sender, FileSystemEventArgs e) { if ((sender == null) || (e == null)) { - Program.ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); + ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); return; } @@ -336,7 +338,7 @@ namespace ArchiSteamFarm { } if (botName.Equals(SharedInfo.ASF)) { - Program.ArchiLogger.LogGenericError(Strings.ErrorGlobalConfigRemoved); + ArchiLogger.LogGenericError(Strings.ErrorGlobalConfigRemoved); Program.Exit(1); return; } @@ -349,7 +351,7 @@ namespace ArchiSteamFarm { private static void OnRenamed(object sender, RenamedEventArgs e) { if ((sender == null) || (e == null)) { - Program.ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); + ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); return; } @@ -359,7 +361,7 @@ namespace ArchiSteamFarm { } if (oldBotName.Equals(SharedInfo.ASF)) { - Program.ArchiLogger.LogGenericError(Strings.ErrorGlobalConfigRemoved); + ArchiLogger.LogGenericError(Strings.ErrorGlobalConfigRemoved); Program.Exit(1); return; } @@ -379,11 +381,11 @@ namespace ArchiSteamFarm { private static async Task RestartOrExit() { if (Program.GlobalConfig.AutoRestart) { - Program.ArchiLogger.LogGenericInfo(Strings.Restarting); + ArchiLogger.LogGenericInfo(Strings.Restarting); await Task.Delay(5000).ConfigureAwait(false); Program.Restart(); } else { - Program.ArchiLogger.LogGenericInfo(Strings.Exiting); + ArchiLogger.LogGenericInfo(Strings.Exiting); await Task.Delay(5000).ConfigureAwait(false); Program.Exit(); } diff --git a/ArchiSteamFarm/ArchiHandler.cs b/ArchiSteamFarm/ArchiHandler.cs index f7da314ef..ef4057463 100644 --- a/ArchiSteamFarm/ArchiHandler.cs +++ b/ArchiSteamFarm/ArchiHandler.cs @@ -395,14 +395,14 @@ namespace ArchiSteamFarm { PurchaseResult = (EPurchaseResult) msg.purchase_result_details; if (msg.purchase_receipt_info == null) { - Program.ArchiLogger.LogNullError(nameof(msg.purchase_receipt_info)); + ASF.ArchiLogger.LogNullError(nameof(msg.purchase_receipt_info)); return; } KeyValue receiptInfo = new KeyValue(); using (MemoryStream ms = new MemoryStream(msg.purchase_receipt_info)) { if (!receiptInfo.TryReadAsBinary(ms)) { - Program.ArchiLogger.LogNullError(nameof(ms)); + ASF.ArchiLogger.LogNullError(nameof(ms)); return; } } @@ -420,14 +420,14 @@ namespace ArchiSteamFarm { // We'll use ItemAppID in this case packageID = lineItem["ItemAppID"].AsUnsignedInteger(); if (packageID == 0) { - Program.ArchiLogger.LogNullError(nameof(packageID)); + ASF.ArchiLogger.LogNullError(nameof(packageID)); return; } } string gameName = lineItem["ItemDescription"].Value; if (string.IsNullOrEmpty(gameName)) { - Program.ArchiLogger.LogNullError(nameof(gameName)); + ASF.ArchiLogger.LogNullError(nameof(gameName)); return; } diff --git a/ArchiSteamFarm/ArchiSteamFarm.csproj b/ArchiSteamFarm/ArchiSteamFarm.csproj index e356c3cac..43487abc4 100644 --- a/ArchiSteamFarm/ArchiSteamFarm.csproj +++ b/ArchiSteamFarm/ArchiSteamFarm.csproj @@ -144,6 +144,7 @@ + diff --git a/ArchiSteamFarm/ArchiWebHandler.cs b/ArchiSteamFarm/ArchiWebHandler.cs index 0a5cee01e..905f1f189 100644 --- a/ArchiSteamFarm/ArchiWebHandler.cs +++ b/ArchiSteamFarm/ArchiWebHandler.cs @@ -1142,7 +1142,7 @@ namespace ArchiSteamFarm { private static uint GetAppIDFromMarketHashName(string hashName) { if (string.IsNullOrEmpty(hashName)) { - Program.ArchiLogger.LogNullError(nameof(hashName)); + ASF.ArchiLogger.LogNullError(nameof(hashName)); return 0; } @@ -1157,7 +1157,7 @@ namespace ArchiSteamFarm { private static Steam.Item.EType GetItemType(string name) { if (string.IsNullOrEmpty(name)) { - Program.ArchiLogger.LogNullError(nameof(name)); + ASF.ArchiLogger.LogNullError(nameof(name)); return Steam.Item.EType.Unknown; } @@ -1194,32 +1194,32 @@ namespace ArchiSteamFarm { private static bool ParseItems(Dictionary> descriptions, List input, HashSet output) { if ((descriptions == null) || (input == null) || (input.Count == 0) || (output == null)) { - Program.ArchiLogger.LogNullError(nameof(descriptions) + " || " + nameof(input) + " || " + nameof(output)); + ASF.ArchiLogger.LogNullError(nameof(descriptions) + " || " + nameof(input) + " || " + nameof(output)); return false; } foreach (KeyValue item in input) { uint appID = item["appid"].AsUnsignedInteger(); if (appID == 0) { - Program.ArchiLogger.LogNullError(nameof(appID)); + ASF.ArchiLogger.LogNullError(nameof(appID)); return false; } ulong contextID = item["contextid"].AsUnsignedLong(); if (contextID == 0) { - Program.ArchiLogger.LogNullError(nameof(contextID)); + ASF.ArchiLogger.LogNullError(nameof(contextID)); return false; } ulong classID = item["classid"].AsUnsignedLong(); if (classID == 0) { - Program.ArchiLogger.LogNullError(nameof(classID)); + ASF.ArchiLogger.LogNullError(nameof(classID)); return false; } uint amount = item["amount"].AsUnsignedInteger(); if (amount == 0) { - Program.ArchiLogger.LogNullError(nameof(amount)); + ASF.ArchiLogger.LogNullError(nameof(amount)); return false; } diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index d1c438ffe..d88f6c60a 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -316,7 +316,7 @@ namespace ArchiSteamFarm { try { return JsonConvert.SerializeObject(response); } catch (JsonException e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); return null; } } @@ -365,7 +365,7 @@ namespace ArchiSteamFarm { internal static async Task InitializeCMs(uint cellID, IServerListProvider serverListProvider) { if (serverListProvider == null) { - Program.ArchiLogger.LogNullError(nameof(serverListProvider)); + ASF.ArchiLogger.LogNullError(nameof(serverListProvider)); return; } @@ -374,16 +374,25 @@ namespace ArchiSteamFarm { // Normally we wouldn't need to do this, but there is a case where our list might be invalid or outdated // Ensure that we always ask once for list of up-to-date servers, even if we have list saved - Program.ArchiLogger.LogGenericInfo(string.Format(Strings.Initializing, nameof(SteamDirectory))); + ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.Initializing, nameof(SteamDirectory))); try { await SteamDirectory.Initialize(cellID).ConfigureAwait(false); - Program.ArchiLogger.LogGenericInfo(Strings.Success); + ASF.ArchiLogger.LogGenericInfo(Strings.Success); } catch { - Program.ArchiLogger.LogGenericWarning(Strings.BotSteamDirectoryInitializationFailed); + ASF.ArchiLogger.LogGenericWarning(Strings.BotSteamDirectoryInitializationFailed); } } + internal bool IsFriend(ulong steamID) { + if (steamID != 0) { + return SteamFriends?.GetFriendRelationship(steamID) == EFriendRelationship.Friend; + } + + ArchiLogger.LogNullError(nameof(steamID)); + return false; + } + internal async Task LootIfNeeded() { if (!BotConfig.SendOnFarmingFinished || (BotConfig.SteamMasterID == 0) || !IsConnectedAndLoggedOn || (BotConfig.SteamMasterID == SteamClient.SteamID)) { return; @@ -645,6 +654,19 @@ namespace ArchiSteamFarm { } } + internal void SendMessage(ulong steamID, string message) { + if ((steamID == 0) || string.IsNullOrEmpty(message)) { + ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(message)); + return; + } + + if (new SteamID(steamID).IsChatAccount) { + SendMessageToChannel(steamID, message); + } else { + SendMessageToUser(steamID, message); + } + } + internal void Stop(bool withShutdownEvent = true) { if (!KeepRunning) { return; @@ -730,7 +752,7 @@ namespace ArchiSteamFarm { private static HashSet GetBots(string args) { if (string.IsNullOrEmpty(args)) { - Program.ArchiLogger.LogNullError(nameof(args)); + ASF.ArchiLogger.LogNullError(nameof(args)); return null; } @@ -933,7 +955,7 @@ namespace ArchiSteamFarm { return (steamID == Program.GlobalConfig.SteamOwnerID) || (Debugging.IsDebugBuild && (steamID == SharedInfo.ArchiSteamID)); } - Program.ArchiLogger.LogNullError(nameof(steamID)); + ASF.ArchiLogger.LogNullError(nameof(steamID)); return false; } @@ -942,7 +964,7 @@ namespace ArchiSteamFarm { return Regex.IsMatch(key, @"^[0-9A-Z]{4,7}-[0-9A-Z]{4,7}-[0-9A-Z]{4,7}(?:(?:-[0-9A-Z]{4,7})?(?:-[0-9A-Z]{4,7}))?$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); } - Program.ArchiLogger.LogNullError(nameof(key)); + ASF.ArchiLogger.LogNullError(nameof(key)); return false; } @@ -1614,7 +1636,7 @@ namespace ArchiSteamFarm { private static async Task Response2FA(ulong steamID, string botNames) { if ((steamID == 0) || string.IsNullOrEmpty(botNames)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); return null; } @@ -1674,7 +1696,7 @@ namespace ArchiSteamFarm { private static async Task Response2FAConfirm(ulong steamID, string botNames, bool confirm) { if ((steamID == 0) || string.IsNullOrEmpty(botNames)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); return null; } @@ -1745,7 +1767,7 @@ namespace ArchiSteamFarm { private async Task ResponseAddLicense(ulong steamID, string games) { if ((steamID == 0) || string.IsNullOrEmpty(games)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(games)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(games)); return null; } @@ -1778,7 +1800,7 @@ namespace ArchiSteamFarm { private static async Task ResponseAddLicense(ulong steamID, string botNames, string games) { if ((steamID == 0) || string.IsNullOrEmpty(botNames) || string.IsNullOrEmpty(games)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames) + " || " + nameof(games)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames) + " || " + nameof(games)); return null; } @@ -1816,13 +1838,13 @@ namespace ArchiSteamFarm { return IsOwner(steamID) ? GetAPIStatus() : null; } - Program.ArchiLogger.LogNullError(nameof(steamID)); + ASF.ArchiLogger.LogNullError(nameof(steamID)); return null; } private static string ResponseExit(ulong steamID) { if (steamID == 0) { - Program.ArchiLogger.LogNullError(nameof(steamID)); + ASF.ArchiLogger.LogNullError(nameof(steamID)); return null; } @@ -1860,7 +1882,7 @@ namespace ArchiSteamFarm { private static async Task ResponseFarm(ulong steamID, string botNames) { if ((steamID == 0) || string.IsNullOrEmpty(botNames)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); return null; } @@ -1954,7 +1976,7 @@ namespace ArchiSteamFarm { private static async Task ResponseLoot(ulong steamID, string botNames) { if ((steamID == 0) || string.IsNullOrEmpty(botNames)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); return null; } @@ -2003,7 +2025,7 @@ namespace ArchiSteamFarm { private static async Task ResponseLootSwitch(ulong steamID, string botNames) { if ((steamID == 0) || string.IsNullOrEmpty(botNames)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); return null; } @@ -2093,7 +2115,7 @@ namespace ArchiSteamFarm { private static async Task ResponseOwns(ulong steamID, string botNames, string query) { if ((steamID == 0) || string.IsNullOrEmpty(botNames) || string.IsNullOrEmpty(query)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames) + " || " + nameof(query)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames) + " || " + nameof(query)); return null; } @@ -2145,7 +2167,7 @@ namespace ArchiSteamFarm { private static async Task ResponsePassword(ulong steamID, string botNames) { if ((steamID == 0) || string.IsNullOrEmpty(botNames)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); return null; } @@ -2208,7 +2230,7 @@ namespace ArchiSteamFarm { private static async Task ResponsePause(ulong steamID, string botNames, bool sticky) { if ((steamID == 0) || string.IsNullOrEmpty(botNames)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); return null; } @@ -2265,7 +2287,7 @@ namespace ArchiSteamFarm { private async Task ResponsePlay(ulong steamID, string games) { if ((steamID == 0) || string.IsNullOrEmpty(games)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(games)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(games)); return null; } @@ -2302,7 +2324,7 @@ namespace ArchiSteamFarm { private static async Task ResponsePlay(ulong steamID, string botNames, string games) { if ((steamID == 0) || string.IsNullOrEmpty(botNames) || string.IsNullOrEmpty(games)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames) + " || " + nameof(games)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames) + " || " + nameof(games)); return null; } @@ -2491,7 +2513,7 @@ namespace ArchiSteamFarm { private static async Task ResponseRedeem(ulong steamID, string botNames, string message, ERedeemFlags redeemFlags = ERedeemFlags.None) { if ((steamID == 0) || string.IsNullOrEmpty(botNames) || string.IsNullOrEmpty(message)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames) + " || " + nameof(message)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames) + " || " + nameof(message)); return null; } @@ -2526,7 +2548,7 @@ namespace ArchiSteamFarm { private static string ResponseRejoinChat(ulong steamID) { if (steamID == 0) { - Program.ArchiLogger.LogNullError(nameof(steamID)); + ASF.ArchiLogger.LogNullError(nameof(steamID)); return null; } @@ -2543,7 +2565,7 @@ namespace ArchiSteamFarm { private static string ResponseRestart(ulong steamID) { if (steamID == 0) { - Program.ArchiLogger.LogNullError(nameof(steamID)); + ASF.ArchiLogger.LogNullError(nameof(steamID)); return null; } @@ -2585,7 +2607,7 @@ namespace ArchiSteamFarm { private static async Task ResponseResume(ulong steamID, string botNames) { if ((steamID == 0) || string.IsNullOrEmpty(botNames)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); return null; } @@ -2639,7 +2661,7 @@ namespace ArchiSteamFarm { private static async Task ResponseStart(ulong steamID, string botNames) { if ((steamID == 0) || string.IsNullOrEmpty(botNames)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); return null; } @@ -2674,7 +2696,7 @@ namespace ArchiSteamFarm { private static string ResponseStartAll(ulong steamID) { if (steamID == 0) { - Program.ArchiLogger.LogNullError(nameof(steamID)); + ASF.ArchiLogger.LogNullError(nameof(steamID)); return null; } @@ -2729,7 +2751,7 @@ namespace ArchiSteamFarm { private static async Task ResponseStatus(ulong steamID, string botNames) { if ((steamID == 0) || string.IsNullOrEmpty(botNames)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); return null; } @@ -2764,7 +2786,7 @@ namespace ArchiSteamFarm { private static string ResponseStatusAll(ulong steamID) { if (steamID == 0) { - Program.ArchiLogger.LogNullError(nameof(steamID)); + ASF.ArchiLogger.LogNullError(nameof(steamID)); return null; } @@ -2798,7 +2820,7 @@ namespace ArchiSteamFarm { private static async Task ResponseStop(ulong steamID, string botNames) { if ((steamID == 0) || string.IsNullOrEmpty(botNames)) { - Program.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); + ASF.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(botNames)); return null; } @@ -2842,7 +2864,7 @@ namespace ArchiSteamFarm { private static async Task ResponseUpdate(ulong steamID) { if (steamID == 0) { - Program.ArchiLogger.LogNullError(nameof(steamID)); + ASF.ArchiLogger.LogNullError(nameof(steamID)); return null; } @@ -2867,19 +2889,6 @@ namespace ArchiSteamFarm { return "ASF V" + SharedInfo.Version; } - private void SendMessage(ulong steamID, string message) { - if ((steamID == 0) || string.IsNullOrEmpty(message)) { - ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(message)); - return; - } - - if (new SteamID(steamID).IsChatAccount) { - SendMessageToChannel(steamID, message); - } else { - SendMessageToUser(steamID, message); - } - } - private void SendMessageToChannel(ulong steamID, string message) { if ((steamID == 0) || string.IsNullOrEmpty(message)) { ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(message)); diff --git a/ArchiSteamFarm/BotConfig.cs b/ArchiSteamFarm/BotConfig.cs index b8b10c623..d9192b659 100644 --- a/ArchiSteamFarm/BotConfig.cs +++ b/ArchiSteamFarm/BotConfig.cs @@ -124,7 +124,7 @@ namespace ArchiSteamFarm { internal static BotConfig Load(string filePath) { if (string.IsNullOrEmpty(filePath)) { - Program.ArchiLogger.LogNullError(nameof(filePath)); + ASF.ArchiLogger.LogNullError(nameof(filePath)); return null; } @@ -137,12 +137,12 @@ namespace ArchiSteamFarm { try { botConfig = JsonConvert.DeserializeObject(File.ReadAllText(filePath)); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); return null; } if (botConfig == null) { - Program.ArchiLogger.LogNullError(nameof(botConfig)); + ASF.ArchiLogger.LogNullError(nameof(botConfig)); return null; } @@ -158,7 +158,7 @@ namespace ArchiSteamFarm { return botConfig; } - Program.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningTooManyGamesToPlay, ArchiHandler.MaxGamesPlayedConcurrently, nameof(botConfig.GamesPlayedWhileIdle))); + ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningTooManyGamesToPlay, ArchiHandler.MaxGamesPlayedConcurrently, nameof(botConfig.GamesPlayedWhileIdle))); HashSet validGames = new HashSet(botConfig.GamesPlayedWhileIdle.Take(ArchiHandler.MaxGamesPlayedConcurrently)); botConfig.GamesPlayedWhileIdle.IntersectWith(validGames); diff --git a/ArchiSteamFarm/BotDatabase.cs b/ArchiSteamFarm/BotDatabase.cs index c7ae66026..74d603b4c 100644 --- a/ArchiSteamFarm/BotDatabase.cs +++ b/ArchiSteamFarm/BotDatabase.cs @@ -82,7 +82,7 @@ namespace ArchiSteamFarm { internal static BotDatabase Load(string filePath) { if (string.IsNullOrEmpty(filePath)) { - Program.ArchiLogger.LogNullError(nameof(filePath)); + ASF.ArchiLogger.LogNullError(nameof(filePath)); return null; } @@ -95,12 +95,12 @@ namespace ArchiSteamFarm { try { botDatabase = JsonConvert.DeserializeObject(File.ReadAllText(filePath)); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); return null; } if (botDatabase == null) { - Program.ArchiLogger.LogNullError(nameof(botDatabase)); + ASF.ArchiLogger.LogNullError(nameof(botDatabase)); return null; } @@ -111,7 +111,7 @@ namespace ArchiSteamFarm { internal void Save() { string json = JsonConvert.SerializeObject(this); if (string.IsNullOrEmpty(json)) { - Program.ArchiLogger.LogNullError(nameof(json)); + ASF.ArchiLogger.LogNullError(nameof(json)); return; } @@ -121,7 +121,7 @@ namespace ArchiSteamFarm { File.WriteAllText(FilePath, json); break; } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); } Thread.Sleep(1000); diff --git a/ArchiSteamFarm/CMsgs/CMsgClientClanInviteAction.cs b/ArchiSteamFarm/CMsgs/CMsgClientClanInviteAction.cs index a3e27d8aa..0d341c27e 100644 --- a/ArchiSteamFarm/CMsgs/CMsgClientClanInviteAction.cs +++ b/ArchiSteamFarm/CMsgs/CMsgClientClanInviteAction.cs @@ -33,7 +33,7 @@ namespace ArchiSteamFarm.CMsgs { void ISteamSerializable.Deserialize(Stream stream) { if (stream == null) { - Program.ArchiLogger.LogNullError(nameof(stream)); + ASF.ArchiLogger.LogNullError(nameof(stream)); return; } @@ -46,7 +46,7 @@ namespace ArchiSteamFarm.CMsgs { void ISteamSerializable.Serialize(Stream stream) { if (stream == null) { - Program.ArchiLogger.LogNullError(nameof(stream)); + ASF.ArchiLogger.LogNullError(nameof(stream)); return; } diff --git a/ArchiSteamFarm/CryptoHelper.cs b/ArchiSteamFarm/CryptoHelper.cs index e830924e3..336ac8048 100644 --- a/ArchiSteamFarm/CryptoHelper.cs +++ b/ArchiSteamFarm/CryptoHelper.cs @@ -32,7 +32,7 @@ namespace ArchiSteamFarm { internal static string Decrypt(ECryptoMethod cryptoMethod, string encrypted) { if (string.IsNullOrEmpty(encrypted)) { - Program.ArchiLogger.LogNullError(nameof(encrypted)); + ASF.ArchiLogger.LogNullError(nameof(encrypted)); return null; } @@ -50,7 +50,7 @@ namespace ArchiSteamFarm { internal static string Encrypt(ECryptoMethod cryptoMethod, string decrypted) { if (string.IsNullOrEmpty(decrypted)) { - Program.ArchiLogger.LogNullError(nameof(decrypted)); + ASF.ArchiLogger.LogNullError(nameof(decrypted)); return null; } @@ -68,7 +68,7 @@ namespace ArchiSteamFarm { internal static void SetEncryptionKey(string key) { if (string.IsNullOrEmpty(key)) { - Program.ArchiLogger.LogNullError(nameof(key)); + ASF.ArchiLogger.LogNullError(nameof(key)); return; } @@ -77,7 +77,7 @@ namespace ArchiSteamFarm { private static string DecryptAES(string encrypted) { if (string.IsNullOrEmpty(encrypted)) { - Program.ArchiLogger.LogNullError(nameof(encrypted)); + ASF.ArchiLogger.LogNullError(nameof(encrypted)); return null; } @@ -91,14 +91,14 @@ namespace ArchiSteamFarm { decryptedData = SteamKit2.CryptoHelper.SymmetricDecrypt(decryptedData, key); return Encoding.UTF8.GetString(decryptedData); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); return null; } } private static string DecryptProtectedDataForCurrentUser(string encrypted) { if (string.IsNullOrEmpty(encrypted)) { - Program.ArchiLogger.LogNullError(nameof(encrypted)); + ASF.ArchiLogger.LogNullError(nameof(encrypted)); return null; } @@ -111,14 +111,14 @@ namespace ArchiSteamFarm { return Encoding.UTF8.GetString(decryptedData); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); return null; } } private static string EncryptAES(string decrypted) { if (string.IsNullOrEmpty(decrypted)) { - Program.ArchiLogger.LogNullError(nameof(decrypted)); + ASF.ArchiLogger.LogNullError(nameof(decrypted)); return null; } @@ -132,14 +132,14 @@ namespace ArchiSteamFarm { encryptedData = SteamKit2.CryptoHelper.SymmetricEncrypt(encryptedData, key); return Convert.ToBase64String(encryptedData); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); return null; } } private static string EncryptProtectedDataForCurrentUser(string decrypted) { if (string.IsNullOrEmpty(decrypted)) { - Program.ArchiLogger.LogNullError(nameof(decrypted)); + ASF.ArchiLogger.LogNullError(nameof(decrypted)); return null; } @@ -152,7 +152,7 @@ namespace ArchiSteamFarm { return Convert.ToBase64String(encryptedData); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); return null; } } diff --git a/ArchiSteamFarm/Debugging.cs b/ArchiSteamFarm/Debugging.cs index 77803d78b..a6dced9a8 100644 --- a/ArchiSteamFarm/Debugging.cs +++ b/ArchiSteamFarm/Debugging.cs @@ -38,11 +38,11 @@ namespace ArchiSteamFarm { internal sealed class DebugListener : IDebugListener { public void WriteLine(string category, string msg) { if (string.IsNullOrEmpty(category) && string.IsNullOrEmpty(msg)) { - Program.ArchiLogger.LogNullError(nameof(category) + " && " + nameof(msg)); + ASF.ArchiLogger.LogNullError(nameof(category) + " && " + nameof(msg)); return; } - Program.ArchiLogger.LogGenericDebug(category + " | " + msg); + ASF.ArchiLogger.LogGenericDebug(category + " | " + msg); } } } diff --git a/ArchiSteamFarm/Events.cs b/ArchiSteamFarm/Events.cs index 44c36e2dc..25cd480f8 100644 --- a/ArchiSteamFarm/Events.cs +++ b/ArchiSteamFarm/Events.cs @@ -34,7 +34,7 @@ namespace ArchiSteamFarm { return; } - Program.ArchiLogger.LogGenericInfo(Strings.NoBotsAreRunning); + ASF.ArchiLogger.LogGenericInfo(Strings.NoBotsAreRunning); await Task.Delay(5000).ConfigureAwait(false); Program.Exit(); } diff --git a/ArchiSteamFarm/GlobalConfig.cs b/ArchiSteamFarm/GlobalConfig.cs index e0fbef0ab..92577031a 100644 --- a/ArchiSteamFarm/GlobalConfig.cs +++ b/ArchiSteamFarm/GlobalConfig.cs @@ -113,7 +113,7 @@ namespace ArchiSteamFarm { internal static GlobalConfig Load(string filePath) { if (string.IsNullOrEmpty(filePath)) { - Program.ArchiLogger.LogNullError(nameof(filePath)); + ASF.ArchiLogger.LogNullError(nameof(filePath)); return null; } @@ -126,12 +126,12 @@ namespace ArchiSteamFarm { try { globalConfig = JsonConvert.DeserializeObject(File.ReadAllText(filePath)); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); return null; } if (globalConfig == null) { - Program.ArchiLogger.LogNullError(nameof(globalConfig)); + ASF.ArchiLogger.LogNullError(nameof(globalConfig)); return null; } @@ -142,24 +142,24 @@ namespace ArchiSteamFarm { case ProtocolType.Udp: break; default: - Program.ArchiLogger.LogGenericError(string.Format(Strings.ErrorConfigPropertyInvalid, nameof(globalConfig.SteamProtocol), globalConfig.SteamProtocol)); + ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorConfigPropertyInvalid, nameof(globalConfig.SteamProtocol), globalConfig.SteamProtocol)); return null; } // User might not know what he's doing // Ensure that he can't screw core ASF variables if (globalConfig.MaxFarmingTime == 0) { - Program.ArchiLogger.LogGenericError(string.Format(Strings.ErrorConfigPropertyInvalid, nameof(globalConfig.MaxFarmingTime), globalConfig.MaxFarmingTime)); + ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorConfigPropertyInvalid, nameof(globalConfig.MaxFarmingTime), globalConfig.MaxFarmingTime)); return null; } if (globalConfig.FarmingDelay == 0) { - Program.ArchiLogger.LogGenericError(string.Format(Strings.ErrorConfigPropertyInvalid, nameof(globalConfig.FarmingDelay), globalConfig.FarmingDelay)); + ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorConfigPropertyInvalid, nameof(globalConfig.FarmingDelay), globalConfig.FarmingDelay)); return null; } if (globalConfig.ConnectionTimeout == 0) { - Program.ArchiLogger.LogGenericError(string.Format(Strings.ErrorConfigPropertyInvalid, nameof(globalConfig.ConnectionTimeout), globalConfig.ConnectionTimeout)); + ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorConfigPropertyInvalid, nameof(globalConfig.ConnectionTimeout), globalConfig.ConnectionTimeout)); return null; } @@ -167,7 +167,7 @@ namespace ArchiSteamFarm { return globalConfig; } - Program.ArchiLogger.LogGenericError(string.Format(Strings.ErrorConfigPropertyInvalid, nameof(globalConfig.WCFPort), globalConfig.WCFPort)); + ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorConfigPropertyInvalid, nameof(globalConfig.WCFPort), globalConfig.WCFPort)); return null; } diff --git a/ArchiSteamFarm/GlobalDatabase.cs b/ArchiSteamFarm/GlobalDatabase.cs index b0005091d..d81aff95d 100644 --- a/ArchiSteamFarm/GlobalDatabase.cs +++ b/ArchiSteamFarm/GlobalDatabase.cs @@ -84,7 +84,7 @@ namespace ArchiSteamFarm { internal static GlobalDatabase Load(string filePath) { if (string.IsNullOrEmpty(filePath)) { - Program.ArchiLogger.LogNullError(nameof(filePath)); + ASF.ArchiLogger.LogNullError(nameof(filePath)); return null; } @@ -97,12 +97,12 @@ namespace ArchiSteamFarm { try { globalDatabase = JsonConvert.DeserializeObject(File.ReadAllText(filePath), CustomSerializerSettings); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); return null; } if (globalDatabase == null) { - Program.ArchiLogger.LogNullError(nameof(globalDatabase)); + ASF.ArchiLogger.LogNullError(nameof(globalDatabase)); return null; } @@ -115,7 +115,7 @@ namespace ArchiSteamFarm { private void Save() { string json = JsonConvert.SerializeObject(this, CustomSerializerSettings); if (string.IsNullOrEmpty(json)) { - Program.ArchiLogger.LogNullError(nameof(json)); + ASF.ArchiLogger.LogNullError(nameof(json)); return; } @@ -125,7 +125,7 @@ namespace ArchiSteamFarm { File.WriteAllText(FilePath, json); break; } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); } Thread.Sleep(1000); diff --git a/ArchiSteamFarm/InMemoryServerListProvider.cs b/ArchiSteamFarm/InMemoryServerListProvider.cs index a2dbd493c..d49ba42af 100644 --- a/ArchiSteamFarm/InMemoryServerListProvider.cs +++ b/ArchiSteamFarm/InMemoryServerListProvider.cs @@ -39,7 +39,7 @@ namespace ArchiSteamFarm { public Task UpdateServerListAsync(IEnumerable endPoints) { if (endPoints == null) { - Program.ArchiLogger.LogNullError(nameof(endPoints)); + ASF.ArchiLogger.LogNullError(nameof(endPoints)); return Task.Delay(0); } diff --git a/ArchiSteamFarm/JSON/Steam.cs b/ArchiSteamFarm/JSON/Steam.cs index 4b6a4e893..5ea24e130 100644 --- a/ArchiSteamFarm/JSON/Steam.cs +++ b/ArchiSteamFarm/JSON/Steam.cs @@ -67,25 +67,25 @@ namespace ArchiSteamFarm.JSON { HtmlNode htmlNode = HtmlDocument.DocumentNode.SelectSingleNode("//div[@class='tradeoffer']"); if (htmlNode == null) { - Program.ArchiLogger.LogNullError(nameof(htmlNode)); + ASF.ArchiLogger.LogNullError(nameof(htmlNode)); return 0; } string id = htmlNode.GetAttributeValue("id", null); if (string.IsNullOrEmpty(id)) { - Program.ArchiLogger.LogNullError(nameof(id)); + ASF.ArchiLogger.LogNullError(nameof(id)); return 0; } int index = id.IndexOf('_'); if (index < 0) { - Program.ArchiLogger.LogNullError(nameof(index)); + ASF.ArchiLogger.LogNullError(nameof(index)); return 0; } index++; if (id.Length <= index) { - Program.ArchiLogger.LogNullError(nameof(id.Length)); + ASF.ArchiLogger.LogNullError(nameof(id.Length)); return 0; } @@ -94,7 +94,7 @@ namespace ArchiSteamFarm.JSON { return _TradeOfferID; } - Program.ArchiLogger.LogNullError(nameof(_TradeOfferID)); + ASF.ArchiLogger.LogNullError(nameof(_TradeOfferID)); return 0; } } @@ -131,13 +131,13 @@ namespace ArchiSteamFarm.JSON { HtmlNode htmlNode = HtmlDocument.DocumentNode.SelectSingleNode("//a/@data-miniprofile"); if (htmlNode == null) { - Program.ArchiLogger.LogNullError(nameof(htmlNode)); + ASF.ArchiLogger.LogNullError(nameof(htmlNode)); return 0; } string miniProfile = htmlNode.GetAttributeValue("data-miniprofile", null); if (string.IsNullOrEmpty(miniProfile)) { - Program.ArchiLogger.LogNullError(nameof(miniProfile)); + ASF.ArchiLogger.LogNullError(nameof(miniProfile)); return 0; } @@ -145,7 +145,7 @@ namespace ArchiSteamFarm.JSON { return _OtherSteamID3; } - Program.ArchiLogger.LogNullError(nameof(_OtherSteamID3)); + ASF.ArchiLogger.LogNullError(nameof(_OtherSteamID3)); return 0; } } @@ -182,7 +182,7 @@ namespace ArchiSteamFarm.JSON { set { if (value == null) { - Program.ArchiLogger.LogNullError(nameof(value)); + ASF.ArchiLogger.LogNullError(nameof(value)); return; } @@ -237,13 +237,13 @@ namespace ArchiSteamFarm.JSON { set { if (string.IsNullOrEmpty(value)) { - Program.ArchiLogger.LogNullError(nameof(value)); + ASF.ArchiLogger.LogNullError(nameof(value)); return; } uint amount; if (!uint.TryParse(value, out amount) || (amount == 0)) { - Program.ArchiLogger.LogNullError(nameof(amount)); + ASF.ArchiLogger.LogNullError(nameof(amount)); return; } @@ -258,13 +258,13 @@ namespace ArchiSteamFarm.JSON { set { if (string.IsNullOrEmpty(value)) { - Program.ArchiLogger.LogNullError(nameof(value)); + ASF.ArchiLogger.LogNullError(nameof(value)); return; } uint appID; if (!uint.TryParse(value, out appID) || (appID == 0)) { - Program.ArchiLogger.LogNullError(nameof(appID)); + ASF.ArchiLogger.LogNullError(nameof(appID)); return; } @@ -278,13 +278,13 @@ namespace ArchiSteamFarm.JSON { set { if (string.IsNullOrEmpty(value)) { - Program.ArchiLogger.LogNullError(nameof(value)); + ASF.ArchiLogger.LogNullError(nameof(value)); return; } ulong assetID; if (!ulong.TryParse(value, out assetID) || (assetID == 0)) { - Program.ArchiLogger.LogNullError(nameof(assetID)); + ASF.ArchiLogger.LogNullError(nameof(assetID)); return; } @@ -299,7 +299,7 @@ namespace ArchiSteamFarm.JSON { set { if (string.IsNullOrEmpty(value)) { - Program.ArchiLogger.LogNullError(nameof(value)); + ASF.ArchiLogger.LogNullError(nameof(value)); return; } @@ -319,13 +319,13 @@ namespace ArchiSteamFarm.JSON { set { if (string.IsNullOrEmpty(value)) { - Program.ArchiLogger.LogNullError(nameof(value)); + ASF.ArchiLogger.LogNullError(nameof(value)); return; } ulong contextID; if (!ulong.TryParse(value, out contextID) || (contextID == 0)) { - Program.ArchiLogger.LogNullError(nameof(contextID)); + ASF.ArchiLogger.LogNullError(nameof(contextID)); return; } @@ -405,7 +405,7 @@ namespace ArchiSteamFarm.JSON { } if (OtherSteamID3 == 0) { - Program.ArchiLogger.LogNullError(nameof(OtherSteamID3)); + ASF.ArchiLogger.LogNullError(nameof(OtherSteamID3)); return 0; } diff --git a/ArchiSteamFarm/Logging.cs b/ArchiSteamFarm/Logging.cs index da2b9c2a0..40127cf9b 100644 --- a/ArchiSteamFarm/Logging.cs +++ b/ArchiSteamFarm/Logging.cs @@ -116,7 +116,7 @@ namespace ArchiSteamFarm { private static void OnConfigurationChanged(object sender, LoggingConfigurationChangedEventArgs e) { if ((sender == null) || (e == null)) { - Program.ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); + ASF.ArchiLogger.LogNullError(nameof(sender) + " || " + nameof(e)); return; } diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index 0e229576d..c6fb5e992 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -34,12 +34,11 @@ using System.ServiceProcess; using System.Threading; using System.Threading.Tasks; using ArchiSteamFarm.Localization; +using NLog.Targets; using SteamKit2; namespace ArchiSteamFarm { internal static class Program { - internal static readonly ArchiLogger ArchiLogger = new ArchiLogger(SharedInfo.ASF); - internal static bool IsWCFRunning => WCF.IsServerRunning; internal static GlobalConfig GlobalConfig { get; private set; } internal static GlobalDatabase GlobalDatabase { get; private set; } @@ -55,7 +54,7 @@ namespace ArchiSteamFarm { internal static void Exit(byte exitCode = 0) { if (exitCode != 0) { - ArchiLogger.LogGenericError(Strings.ErrorExitingWithNonZeroErrorCode); + ASF.ArchiLogger.LogGenericError(Strings.ErrorExitingWithNonZeroErrorCode); } Shutdown(); @@ -68,7 +67,7 @@ namespace ArchiSteamFarm { } if (GlobalConfig.Headless || !Runtime.IsUserInteractive) { - ArchiLogger.LogGenericWarning(Strings.ErrorUserInputRunningInHeadlessMode); + ASF.ArchiLogger.LogGenericWarning(Strings.ErrorUserInputRunningInHeadlessMode); return null; } @@ -98,7 +97,7 @@ namespace ArchiSteamFarm { Console.Write(Strings.UserInputWCFHost, botName); break; default: - ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(userInputType), userInputType)); + ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(userInputType), userInputType)); Console.Write(Strings.UserInputUnknown, botName, userInputType); break; } @@ -123,7 +122,7 @@ namespace ArchiSteamFarm { try { Process.Start(Assembly.GetEntryAssembly().Location, string.Join(" ", Environment.GetCommandLineArgs().Skip(1))); } catch (Exception e) { - ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); } ShutdownResetEvent.Set(); @@ -131,6 +130,12 @@ namespace ArchiSteamFarm { } private static async Task Init(string[] args) { + // We must register our logging target as soon as possible + Target.Register("Steam"); + await InitCore(args).ConfigureAwait(false); + } + + private static async Task InitCore(string[] args) { AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; TaskScheduler.UnobservedTaskException += UnobservedTaskExceptionHandler; @@ -161,12 +166,12 @@ namespace ArchiSteamFarm { } Logging.InitLoggers(); - ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version); + ASF.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version); await InitServices().ConfigureAwait(false); if (!Runtime.IsRuntimeSupported) { - ArchiLogger.LogGenericError(Strings.WarningRuntimeUnsupported); + ASF.ArchiLogger.LogGenericError(Strings.WarningRuntimeUnsupported); await Task.Delay(10 * 1000).ConfigureAwait(false); } @@ -177,7 +182,7 @@ namespace ArchiSteamFarm { Directory.Delete(SharedInfo.DebugDirectory, true); await Task.Delay(1000).ConfigureAwait(false); // Dirty workaround giving Windows some time to sync } catch (IOException e) { - ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); } } @@ -207,7 +212,7 @@ namespace ArchiSteamFarm { GlobalConfig = GlobalConfig.Load(globalConfigFile); if (GlobalConfig == null) { - ArchiLogger.LogGenericError(string.Format(Strings.ErrorGlobalConfigNotLoaded, globalConfigFile)); + ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorGlobalConfigNotLoaded, globalConfigFile)); await Task.Delay(5 * 1000).ConfigureAwait(false); Exit(1); return; @@ -219,7 +224,7 @@ namespace ArchiSteamFarm { CultureInfo culture = CultureInfo.CreateSpecificCulture(GlobalConfig.CurrentCulture); CultureInfo.DefaultThreadCurrentCulture = CultureInfo.DefaultThreadCurrentUICulture = culture; } catch (CultureNotFoundException) { - ArchiLogger.LogGenericError(Strings.ErrorInvalidCurrentCulture); + ASF.ArchiLogger.LogGenericError(Strings.ErrorInvalidCurrentCulture); } } @@ -238,20 +243,20 @@ namespace ArchiSteamFarm { if (currentResourceSetCount < defaultResourceSetCount) { float translationCompleteness = currentResourceSetCount / (float) defaultResourceSetCount; - ArchiLogger.LogGenericInfo(string.Format(Strings.TranslationIncomplete, CultureInfo.CurrentCulture.Name, translationCompleteness.ToString("P1"))); + ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.TranslationIncomplete, CultureInfo.CurrentCulture.Name, translationCompleteness.ToString("P1"))); } string globalDatabaseFile = Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalDatabaseFileName); if (!File.Exists(globalDatabaseFile)) { - ArchiLogger.LogGenericInfo(Strings.Welcome); - ArchiLogger.LogGenericWarning(Strings.WarningPrivacyPolicy); + ASF.ArchiLogger.LogGenericInfo(Strings.Welcome); + ASF.ArchiLogger.LogGenericWarning(Strings.WarningPrivacyPolicy); await Task.Delay(15 * 1000).ConfigureAwait(false); } GlobalDatabase = GlobalDatabase.Load(globalDatabaseFile); if (GlobalDatabase == null) { - ArchiLogger.LogGenericError(string.Format(Strings.ErrorDatabaseInvalid, globalDatabaseFile)); + ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorDatabaseInvalid, globalDatabaseFile)); await Task.Delay(5 * 1000).ConfigureAwait(false); Exit(1); return; @@ -261,7 +266,7 @@ namespace ArchiSteamFarm { WebBrowser.Init(); WCF.Init(); - WebBrowser = new WebBrowser(ArchiLogger); + WebBrowser = new WebBrowser(ASF.ArchiLogger); } private static bool InitShutdownSequence() { @@ -300,7 +305,7 @@ namespace ArchiSteamFarm { private static async Task ParsePostInitArgs(IEnumerable args) { if (args == null) { - ArchiLogger.LogNullError(nameof(args)); + ASF.ArchiLogger.LogNullError(nameof(args)); return; } @@ -326,13 +331,13 @@ namespace ArchiSteamFarm { } if (!Mode.HasFlag(EMode.Client)) { - ArchiLogger.LogGenericWarning(string.Format(Strings.WarningWCFIgnoringCommand, arg)); + ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningWCFIgnoringCommand, arg)); break; } string response = WCF.SendCommand(arg); - ArchiLogger.LogGenericInfo(string.Format(Strings.WCFResponseReceived, response)); + ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFResponseReceived, response)); break; } } @@ -340,7 +345,7 @@ namespace ArchiSteamFarm { private static void ParsePreInitArgs(IEnumerable args) { if (args == null) { - ArchiLogger.LogNullError(nameof(args)); + ASF.ArchiLogger.LogNullError(nameof(args)); return; } @@ -376,21 +381,21 @@ namespace ArchiSteamFarm { private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) { if (args?.ExceptionObject == null) { - ArchiLogger.LogNullError(nameof(args) + " || " + nameof(args.ExceptionObject)); + ASF.ArchiLogger.LogNullError(nameof(args) + " || " + nameof(args.ExceptionObject)); return; } - ArchiLogger.LogFatalException((Exception) args.ExceptionObject); + ASF.ArchiLogger.LogFatalException((Exception) args.ExceptionObject); Exit(1); } private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) { if (args?.Exception == null) { - ArchiLogger.LogNullError(nameof(args) + " || " + nameof(args.Exception)); + ASF.ArchiLogger.LogNullError(nameof(args) + " || " + nameof(args.Exception)); return; } - ArchiLogger.LogFatalException(args.Exception); + ASF.ArchiLogger.LogFatalException(args.Exception); Exit(1); } diff --git a/ArchiSteamFarm/Runtime.cs b/ArchiSteamFarm/Runtime.cs index 03fd04b76..d4e709f72 100644 --- a/ArchiSteamFarm/Runtime.cs +++ b/ArchiSteamFarm/Runtime.cs @@ -40,42 +40,42 @@ namespace ArchiSteamFarm { if (IsRunningOnMono) { Version monoVersion = GetMonoVersion(); if (monoVersion == null) { - Program.ArchiLogger.LogNullError(nameof(monoVersion)); + ASF.ArchiLogger.LogNullError(nameof(monoVersion)); return false; } Version minMonoVersion = new Version(4, 6); if (monoVersion >= minMonoVersion) { - Program.ArchiLogger.LogGenericInfo(string.Format(Strings.RuntimeVersionOK, "Mono")); - Program.ArchiLogger.LogGenericInfo(string.Format(Strings.RuntimeVersionComparison, minMonoVersion, monoVersion)); + ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.RuntimeVersionOK, "Mono")); + ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.RuntimeVersionComparison, minMonoVersion, monoVersion)); _IsRuntimeSupported = true; return true; } - Program.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningRuntimeVersionTooOld, "Mono")); - Program.ArchiLogger.LogGenericWarning(string.Format(Strings.RuntimeVersionComparison, minMonoVersion, monoVersion)); + ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningRuntimeVersionTooOld, "Mono")); + ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.RuntimeVersionComparison, minMonoVersion, monoVersion)); _IsRuntimeSupported = false; return false; } Version netVersion = GetNetVersion(); if (netVersion == null) { - Program.ArchiLogger.LogNullError(nameof(netVersion)); + ASF.ArchiLogger.LogNullError(nameof(netVersion)); return false; } Version minNetVersion = new Version(4, 6, 1); if (netVersion >= minNetVersion) { - Program.ArchiLogger.LogGenericInfo(string.Format(Strings.RuntimeVersionOK, ".NET")); - Program.ArchiLogger.LogGenericInfo(string.Format(Strings.RuntimeVersionComparison, minNetVersion, netVersion)); + ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.RuntimeVersionOK, ".NET")); + ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.RuntimeVersionComparison, minNetVersion, netVersion)); _IsRuntimeSupported = true; return true; } - Program.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningRuntimeVersionTooOld, ".NET")); - Program.ArchiLogger.LogGenericWarning(string.Format(Strings.RuntimeVersionComparison, minNetVersion, netVersion)); + ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningRuntimeVersionTooOld, ".NET")); + ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.RuntimeVersionComparison, minNetVersion, netVersion)); _IsRuntimeSupported = false; return false; } @@ -112,25 +112,25 @@ namespace ArchiSteamFarm { private static Version GetMonoVersion() { if (MonoRuntime == null) { - Program.ArchiLogger.LogNullError(nameof(MonoRuntime)); + ASF.ArchiLogger.LogNullError(nameof(MonoRuntime)); return null; } MethodInfo displayName = MonoRuntime.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); if (displayName == null) { - Program.ArchiLogger.LogNullError(nameof(displayName)); + ASF.ArchiLogger.LogNullError(nameof(displayName)); return null; } string versionString = (string) displayName.Invoke(null, null); if (string.IsNullOrEmpty(versionString)) { - Program.ArchiLogger.LogNullError(nameof(versionString)); + ASF.ArchiLogger.LogNullError(nameof(versionString)); return null; } int index = versionString.IndexOf(' '); if (index <= 0) { - Program.ArchiLogger.LogNullError(nameof(index)); + ASF.ArchiLogger.LogNullError(nameof(index)); return null; } @@ -141,7 +141,7 @@ namespace ArchiSteamFarm { return version; } - Program.ArchiLogger.LogNullError(nameof(version)); + ASF.ArchiLogger.LogNullError(nameof(version)); return null; } @@ -149,18 +149,18 @@ namespace ArchiSteamFarm { uint release; using (RegistryKey registryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\")) { if (registryKey == null) { - Program.ArchiLogger.LogNullError(nameof(registryKey)); + ASF.ArchiLogger.LogNullError(nameof(registryKey)); return null; } object releaseObj = registryKey.GetValue("Release"); if (releaseObj == null) { - Program.ArchiLogger.LogNullError(nameof(releaseObj)); + ASF.ArchiLogger.LogNullError(nameof(releaseObj)); return null; } if (!uint.TryParse(releaseObj.ToString(), out release) || (release == 0)) { - Program.ArchiLogger.LogNullError(nameof(release)); + ASF.ArchiLogger.LogNullError(nameof(release)); return null; } } diff --git a/ArchiSteamFarm/Statistics.cs b/ArchiSteamFarm/Statistics.cs index 603241b4b..56e623274 100644 --- a/ArchiSteamFarm/Statistics.cs +++ b/ArchiSteamFarm/Statistics.cs @@ -87,7 +87,7 @@ namespace ArchiSteamFarm { internal async Task OnPersonaState(SteamFriends.PersonaStateCallback callback) { if (callback == null) { - Program.ArchiLogger.LogNullError(nameof(callback)); + ASF.ArchiLogger.LogNullError(nameof(callback)); return; } diff --git a/ArchiSteamFarm/SteamTarget.cs b/ArchiSteamFarm/SteamTarget.cs new file mode 100644 index 000000000..3408db251 --- /dev/null +++ b/ArchiSteamFarm/SteamTarget.cs @@ -0,0 +1,82 @@ +/* + _ _ _ ____ _ _____ + / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___ + / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \ + / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | | +/_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_| + + Copyright 2015-2017 Łukasz "JustArchi" Domeradzki + Contact: JustArchi@JustArchi.net + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using NLog; +using NLog.Config; +using NLog.Targets; + +namespace ArchiSteamFarm { + [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] + [Target("Steam")] + internal sealed class SteamTarget : TargetWithLayout { + [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] + [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] + // This is NLog config property, it must have public get() and set() capabilities + public string BotName { get; set; } + + [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] + [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] + [RequiredParameter] + // This is NLog config property, it must have public get() and set() capabilities + public ulong SteamID { get; set; } + + [SuppressMessage("ReSharper", "EmptyConstructor")] + public SteamTarget() { + // This constructor is intentionally empty and public, as NLog uses it for creating targets + // It must stay like this as we want to have SteamTargets defined in our NLog.config + } + + protected override void Write(LogEventInfo logEvent) { + if (logEvent == null) { + ASF.ArchiLogger.LogNullError(nameof(logEvent)); + return; + } + + if (SteamID == 0) { + return; + } + + Bot bot; + if (string.IsNullOrEmpty(BotName)) { + bot = Bot.Bots.Values.FirstOrDefault(targetBot => targetBot.IsConnectedAndLoggedOn && targetBot.IsFriend(SteamID)); + if (bot == null) { + return; + } + } else { + if (!Bot.Bots.TryGetValue(BotName, out bot)) { + return; + } + } + + string message = Layout.Render(logEvent); + if (string.IsNullOrEmpty(message)) { + return; + } + + bot.SendMessage(SteamID, message); + } + } +} \ No newline at end of file diff --git a/ArchiSteamFarm/Utilities.cs b/ArchiSteamFarm/Utilities.cs index 70a042e45..1450699ce 100644 --- a/ArchiSteamFarm/Utilities.cs +++ b/ArchiSteamFarm/Utilities.cs @@ -42,7 +42,7 @@ namespace ArchiSteamFarm { internal static string GetCookieValue(this CookieContainer cookieContainer, string url, string name) { if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(name)) { - Program.ArchiLogger.LogNullError(nameof(url) + " || " + nameof(name)); + ASF.ArchiLogger.LogNullError(nameof(url) + " || " + nameof(name)); return null; } @@ -51,7 +51,7 @@ namespace ArchiSteamFarm { try { uri = new Uri(url); } catch (UriFormatException e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); return null; } @@ -64,7 +64,7 @@ namespace ArchiSteamFarm { /* internal static int RandomNext(int maxWithout) { if (maxWithout <= 0) { - Program.ArchiLogger.LogNullError(nameof(maxWithout)); + ASF.ArchiLogger.LogNullError(nameof(maxWithout)); return -1; } @@ -80,7 +80,7 @@ namespace ArchiSteamFarm { internal static bool IsValidHexadecimalString(string text) { if (string.IsNullOrEmpty(text)) { - Program.ArchiLogger.LogNullError(nameof(text)); + ASF.ArchiLogger.LogNullError(nameof(text)); return false; } diff --git a/ArchiSteamFarm/WCF.cs b/ArchiSteamFarm/WCF.cs index 8d9270a39..00a9f9f30 100644 --- a/ArchiSteamFarm/WCF.cs +++ b/ArchiSteamFarm/WCF.cs @@ -55,7 +55,7 @@ namespace ArchiSteamFarm { public string HandleCommand(string input) { if (string.IsNullOrEmpty(input)) { - Program.ArchiLogger.LogNullError(nameof(input)); + ASF.ArchiLogger.LogNullError(nameof(input)); return null; } @@ -74,7 +74,7 @@ namespace ArchiSteamFarm { // We must keep it synchronous until either Mono gets fixed, or culprit for freeze located (and corrected) string output = bot.Response(Program.GlobalConfig.SteamOwnerID, command).Result; - Program.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFAnswered, input, output)); + ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFAnswered, input, output)); return output; } @@ -91,11 +91,11 @@ namespace ArchiSteamFarm { internal string SendCommand(string input) { if (string.IsNullOrEmpty(input)) { - Program.ArchiLogger.LogNullError(nameof(input)); + ASF.ArchiLogger.LogNullError(nameof(input)); return null; } - Program.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFSendingCommand, input, URL)); + ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFSendingCommand, input, URL)); if (Client == null) { Client = new Client( @@ -117,7 +117,7 @@ namespace ArchiSteamFarm { return; } - Program.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFStarting, URL)); + ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFStarting, URL)); try { ServiceHost = new ServiceHost(typeof(WCF), new Uri(URL)); @@ -133,11 +133,11 @@ namespace ArchiSteamFarm { ); ServiceHost.Open(); - Program.ArchiLogger.LogGenericInfo(Strings.WCFReady); + ASF.ArchiLogger.LogGenericInfo(Strings.WCFReady); } catch (AddressAccessDeniedException) { - Program.ArchiLogger.LogGenericError(Strings.ErrorWCFAddressAccessDeniedException); + ASF.ArchiLogger.LogGenericError(Strings.ErrorWCFAddressAccessDeniedException); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); } } @@ -150,7 +150,7 @@ namespace ArchiSteamFarm { try { ServiceHost.Close(); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); } } @@ -175,14 +175,14 @@ namespace ArchiSteamFarm { internal string HandleCommand(string input) { if (string.IsNullOrEmpty(input)) { - Program.ArchiLogger.LogNullError(nameof(input)); + ASF.ArchiLogger.LogNullError(nameof(input)); return null; } try { return Channel.HandleCommand(input); } catch (Exception e) { - Program.ArchiLogger.LogGenericException(e); + ASF.ArchiLogger.LogGenericException(e); return null; } } diff --git a/GUI/GUI.csproj b/GUI/GUI.csproj index 47e5ce9af..d2d1e88e4 100644 --- a/GUI/GUI.csproj +++ b/GUI/GUI.csproj @@ -160,6 +160,9 @@ SteamSaleEvent.cs + + SteamTarget.cs + Trading.cs