Skip to content

Commit

Permalink
Some finalizing for 0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Splamy committed Mar 16, 2020
1 parent 1462b0d commit 7cb413a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
38 changes: 32 additions & 6 deletions TS3AudioBot/Environment/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<string, StatsFactory>()
{
{"youtube", new StatsFactory{
PlayRequests = 100,
PlayFromUser = 42,
Playtime = TimeSpan.FromMinutes(12.34),
SearchRequests = 5,
}}
};

return JsonConvert.SerializeObject(sendData, Formatting.Indented);
}
}

internal class StatsPing : StatsData
Expand Down
13 changes: 9 additions & 4 deletions TS3AudioBot/Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <file> 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":
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7cb413a

Please sign in to comment.