From e8120f172f10041ee664991a7d3b2f2309282410 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Tue, 13 Jun 2017 07:35:41 +0200 Subject: [PATCH] Add !stats command --- ArchiSteamFarm/Bot.cs | 16 ++++++++++++++++ ArchiSteamFarm/Localization/Strings.Designer.cs | 11 ++++++++++- ArchiSteamFarm/Localization/Strings.resx | 4 ++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 8ab0faa38..931c46246 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -663,6 +663,8 @@ namespace ArchiSteamFarm { return ResponseRestart(steamID); case "!SA": return await ResponseStatus(steamID, SharedInfo.ASF).ConfigureAwait(false); + case "!STATS": + return ResponseStats(steamID); case "!STATUS": return ResponseStatus(steamID); case "!STOP": @@ -3300,6 +3302,20 @@ namespace ArchiSteamFarm { return responses.Count > 0 ? string.Join("", responses) : null; } + private string ResponseStats(ulong steamID) { + if (steamID == 0) { + ArchiLogger.LogNullError(nameof(steamID)); + return null; + } + + if (!IsOwner(steamID)) { + return null; + } + + ushort memoryInMegabytes = (ushort) (GC.GetTotalMemory(true) / 1024 / 1024); + return FormatBotResponse(string.Format(Strings.BotStats, memoryInMegabytes)); + } + private string ResponseStatus(ulong steamID) { if (steamID == 0) { ArchiLogger.LogNullError(nameof(steamID)); diff --git a/ArchiSteamFarm/Localization/Strings.Designer.cs b/ArchiSteamFarm/Localization/Strings.Designer.cs index b63d73858..10df44f2a 100644 --- a/ArchiSteamFarm/Localization/Strings.Designer.cs +++ b/ArchiSteamFarm/Localization/Strings.Designer.cs @@ -19,7 +19,7 @@ namespace ArchiSteamFarm.Localization { // przez narzędzie, takie jak ResGen lub Visual Studio. // Aby dodać lub usunąć członka, edytuj plik .ResX, a następnie ponownie uruchom ResGen // z opcją /str lub ponownie utwórz projekt VS. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Strings { @@ -537,6 +537,15 @@ namespace ArchiSteamFarm.Localization { } } + /// + /// Wyszukuje zlokalizowany ciąg podobny do ciągu Current memory usage: {0} MB.. + /// + internal static string BotStats { + get { + return ResourceManager.GetString("BotStats", resourceCulture); + } + } + /// /// Wyszukuje zlokalizowany ciąg podobny do ciągu Bot is connecting to Steam network.. /// diff --git a/ArchiSteamFarm/Localization/Strings.resx b/ArchiSteamFarm/Localization/Strings.resx index 09ea69cb4..6c1abdffe 100644 --- a/ArchiSteamFarm/Localization/Strings.resx +++ b/ArchiSteamFarm/Localization/Strings.resx @@ -691,4 +691,8 @@ StackTrace: You're using a version that is newer than latest released version for your update channel. Please note that pre-release versions are dedicated to users who know how to report bugs, deal with issues and give feedback - no technical support will be given. + + Current memory usage: {0} MB. + {0} will be replaced by number (in megabytes) of memory being used + \ No newline at end of file