From c22930eb7a26dd17474d229e4fa8105e9f2981eb Mon Sep 17 00:00:00 2001 From: Ryzhehvost Date: Sat, 13 Jul 2019 22:38:10 +0300 Subject: [PATCH] Remove time convertor, it's not needed anymore. Also improved logging/responses --- ArchiSteamFarm | 2 +- BoosterCreator.sln | 4 +-- BoosterCreator/BoosterCreator.cs | 4 +-- BoosterCreator/BoosterCreator.csproj | 13 +++++---- BoosterCreator/BoosterHandler.cs | 43 ++++++++++++++++++---------- BoosterCreator/ValveTimeZone.cs | 26 ----------------- build.bat | 4 +++ 7 files changed, 45 insertions(+), 51 deletions(-) delete mode 100644 BoosterCreator/ValveTimeZone.cs create mode 100644 build.bat diff --git a/ArchiSteamFarm b/ArchiSteamFarm index 5a2f4b8..a76fe94 160000 --- a/ArchiSteamFarm +++ b/ArchiSteamFarm @@ -1 +1 @@ -Subproject commit 5a2f4b89c708b7319784afbf136f2effa80db786 +Subproject commit a76fe94617632a2dcf03ea26278549b08f750e36 diff --git a/BoosterCreator.sln b/BoosterCreator.sln index 1a9c2ca..72f9a8e 100644 --- a/BoosterCreator.sln +++ b/BoosterCreator.sln @@ -17,8 +17,8 @@ Global {C485E0CB-4D22-4A09-8CBA-83D1300A83DC}.Debug|Any CPU.Build.0 = Debug|Any CPU {C485E0CB-4D22-4A09-8CBA-83D1300A83DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {C485E0CB-4D22-4A09-8CBA-83D1300A83DC}.Release|Any CPU.Build.0 = Release|Any CPU - {CF84911C-2C4C-4195-8AF3-ABBB6D3DE9AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CF84911C-2C4C-4195-8AF3-ABBB6D3DE9AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CF84911C-2C4C-4195-8AF3-ABBB6D3DE9AA}.Debug|Any CPU.ActiveCfg = Release|Any CPU + {CF84911C-2C4C-4195-8AF3-ABBB6D3DE9AA}.Debug|Any CPU.Build.0 = Release|Any CPU {CF84911C-2C4C-4195-8AF3-ABBB6D3DE9AA}.Release|Any CPU.ActiveCfg = Release|Any CPU {CF84911C-2C4C-4195-8AF3-ABBB6D3DE9AA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection diff --git a/BoosterCreator/BoosterCreator.cs b/BoosterCreator/BoosterCreator.cs index 3c398dd..5bd318a 100644 --- a/BoosterCreator/BoosterCreator.cs +++ b/BoosterCreator/BoosterCreator.cs @@ -13,7 +13,7 @@ public sealed class BoosterCreator : IBotModules, IBotCommand { public string Name => nameof(BoosterCreator); public Version Version => typeof(BoosterCreator).Assembly.GetName().Version; - public void OnLoaded() => ASF.ArchiLogger.LogGenericInfo("BoosterCreator ASF Plugin by Out | Support: https://steamcommunity.com/id/outzzz"); + public void OnLoaded() => ASF.ArchiLogger.LogGenericInfo("BoosterCreator ASF Plugin by Out (https://steamcommunity.com/id/outzzz) | fork by Ryzhehvost"); public async Task OnBotCommand(Bot bot, ulong steamID, string message, string[] args) => await Commands.Response(bot, steamID, message, args).ConfigureAwait(false); @@ -30,7 +30,7 @@ public async void OnBotInitModules(Bot bot, IReadOnlyDictionary BoosterHandler.BoosterHandlers[bot.BotName] = null; } - bot.ArchiLogger.LogGenericInfo("GamesToBooster:" + string.Join(",", configProperty.Value)); + bot.ArchiLogger.LogGenericInfo("GamesToBooster : " + string.Join(",", configProperty.Value)); await Task.Run(() => BoosterHandler.BoosterHandlers[bot.BotName] = new BoosterHandler(bot, configProperty.Value.ToObject>())).ConfigureAwait(false); break; } diff --git a/BoosterCreator/BoosterCreator.csproj b/BoosterCreator/BoosterCreator.csproj index bf02ce0..4633b02 100644 --- a/BoosterCreator/BoosterCreator.csproj +++ b/BoosterCreator/BoosterCreator.csproj @@ -7,17 +7,20 @@ - + - + + - - ..\ArchiSteamFarm\ArchiSteamFarm\lib\SteamKit2.dll - + + + + + diff --git a/BoosterCreator/BoosterHandler.cs b/BoosterCreator/BoosterHandler.cs index 92b1d33..92f114b 100644 --- a/BoosterCreator/BoosterHandler.cs +++ b/BoosterCreator/BoosterHandler.cs @@ -24,8 +24,9 @@ internal sealed class BoosterHandler : IDisposable { internal BoosterHandler([NotNull] Bot bot, IReadOnlyCollection gameIDs) { Bot = bot ?? throw new ArgumentNullException(nameof(bot)); - foreach (var gameID in gameIDs) { + foreach (uint gameID in gameIDs) { GameIDs.TryAdd(gameID, DateTime.Now.AddHours(1)); + ASF.ArchiLogger.LogGenericInfo(Commands.FormatBotResponse(bot, "Auto-attepmt to make booster from " + gameID.ToString() + " is planned at " + GameIDs[gameID].Value.ToShortDateString() + " " + GameIDs[gameID].Value.ToShortTimeString())); } BoosterTimer = new Timer( @@ -43,8 +44,9 @@ private async Task AutoBooster() { return; } - string response = await CreateBooster(Bot, GameIDs).ConfigureAwait(false); - ASF.ArchiLogger.LogGenericInfo(response); + //string response = + await CreateBooster(Bot, GameIDs).ConfigureAwait(false); + //ASF.ArchiLogger.LogGenericInfo(response); } internal static async Task CreateBooster(Bot bot, ConcurrentDictionary gameIDs) { @@ -59,14 +61,16 @@ internal static async Task CreateBooster(Bot bot, ConcurrentDictionary CreateBooster(Bot bot, ConcurrentDictionary gameID in gameIDs) { if (!gameID.Value.HasValue || DateTime.Compare(gameID.Value.Value, DateTime.Now) <= 0) { await Task.Delay(500).ConfigureAwait(false); if (!boosterInfos.ContainsKey(gameID.Key)) { - response.AppendLine(Commands.FormatBotResponse(bot, string.Format(Strings.BotAddLicense, gameID, "NotEligible"))); + response.AppendLine(Commands.FormatBotResponse(bot, "Not eligible to create boosters from " + gameID.Key.ToString())); + ASF.ArchiLogger.LogGenericInfo(Commands.FormatBotResponse(bot, "Not eligible to create boosters from " + gameID.Key.ToString())); //If we are not eligible - wait 8 hours, just in case game will be added to account later if (gameID.Value.HasValue) { //if source is timer, not command gameIDs[gameID.Key] = DateTime.Now.AddHours(8); + ASF.ArchiLogger.LogGenericInfo(Commands.FormatBotResponse(bot, "Next attepmt to make booster from " + gameID.Key.ToString() + " is planned at " + gameIDs[gameID.Key].Value.ToShortDateString() + " " + gameIDs[gameID.Key].Value.ToShortTimeString())); } continue; } @@ -93,23 +99,26 @@ internal static async Task CreateBooster(Bot bot, ConcurrentDictionary CreateBooster(Bot bot, ConcurrentDictionary CreateBooster(Bot bot, ConcurrentDictionary