From 7cb413a17e088dadf1f6179bc54c3f38bcd1f4e3 Mon Sep 17 00:00:00 2001 From: Splamy Date: Mon, 16 Mar 2020 13:37:09 +0100 Subject: [PATCH] Some finalizing for 0.11 --- TS3AudioBot/Environment/Stats.cs | 38 +++++++++++++++++++++++++++----- TS3AudioBot/Setup.cs | 13 +++++++---- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/TS3AudioBot/Environment/Stats.cs b/TS3AudioBot/Environment/Stats.cs index 21f0ad31..3402af6b 100644 --- a/TS3AudioBot/Environment/Stats.cs +++ b/TS3AudioBot/Environment/Stats.cs @@ -129,12 +129,7 @@ private void SendStats(StatsPing sendPacket) private StatsPing GetStatsTill(DateTime date) { - var sendPacket = new StatsPing - { - BotVersion = SystemData.AssemblyData.ToString(), - Platform = SystemData.PlatformData, - Runtime = SystemData.RuntimeData.FullName, - }; + var sendPacket = GetDefaultStatsPing(); uint count = 0; uint avgBots = 0; @@ -218,6 +213,37 @@ public void TrackSongStop(Id bot) statsFactory.Playtime += (Tools.Now - runtimeLastTrack); } } + + private static StatsPing GetDefaultStatsPing() + { + return new StatsPing + { + BotVersion = SystemData.AssemblyData.ToString(), + Platform = SystemData.PlatformData, + Runtime = SystemData.RuntimeData.FullName, + }; + } + + public static string CreateExample() + { + var sendData = GetDefaultStatsPing(); + sendData.TotalUptime = TimeSpan.FromHours(12.34); + sendData.BotsRuntime = TimeSpan.FromHours(4.20); + sendData.CommandCalls = 1234; + sendData.CommandFromApi = 100; + sendData.RunningBots = 3; + sendData.SongStats = new Dictionary() + { + {"youtube", new StatsFactory{ + PlayRequests = 100, + PlayFromUser = 42, + Playtime = TimeSpan.FromMinutes(12.34), + SearchRequests = 5, + }} + }; + + return JsonConvert.SerializeObject(sendData, Formatting.Indented); + } } internal class StatsPing : StatsData diff --git a/TS3AudioBot/Setup.cs b/TS3AudioBot/Setup.cs index 9c47a06e..7b73a355 100644 --- a/TS3AudioBot/Setup.cs +++ b/TS3AudioBot/Setup.cs @@ -101,12 +101,14 @@ public static ParameterData ReadParameter(string[] args) case "?": case "-h": case "--help": + Console.WriteLine(" --help -h Prints this help..."); Console.WriteLine(" --config -c Specifies the path to the config file."); Console.WriteLine(" --version -V Gets the bot version."); Console.WriteLine(" --skip-checks Skips checking the system for all required tools."); Console.WriteLine(" --hide-banner Does not print the version information header."); Console.WriteLine(" --non-interactive Disables console prompts from setup tools."); - Console.WriteLine(" --help -h Prints this help..."); + Console.WriteLine(" --stats-example Shows you what the bot sends to the global stats tracker."); + Console.WriteLine(" --stats-disabled Disables sending to the global stats tracker."); return Cancel(); case "-c": @@ -136,8 +138,12 @@ public static ParameterData ReadParameter(string[] args) break; case "--stats-example": - data.StatsExample = true; - break; + Console.WriteLine("The bot will contribute to the stats counter about once per day."); + Console.WriteLine("We do NOT store any IP or identifiable information."); + Console.WriteLine("Please keep this feature enabled to help us improve and grow."); + Console.WriteLine("An example stats packet looks like this:"); + Console.WriteLine(Stats.CreateExample()); + return Cancel(); case "--stats-disabled": data.SendStats = false; @@ -184,7 +190,6 @@ internal class ParameterData public bool Interactive { get; set; } = true; public bool Llgc { get; set; } = true; public bool SendStats { get; set; } = true; - public bool StatsExample { get; set; } = false; } internal enum ExitType