From 4198201a18305746bf7348eba7db42c40d69e702 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Tue, 3 May 2016 19:35:36 +0200 Subject: [PATCH] Added message counter and msg/sec --- NadekoBot/Classes/NadekoStats.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/NadekoBot/Classes/NadekoStats.cs b/NadekoBot/Classes/NadekoStats.cs index ba4187de..f5f7766f 100644 --- a/NadekoBot/Classes/NadekoStats.cs +++ b/NadekoBot/Classes/NadekoStats.cs @@ -31,6 +31,9 @@ namespace NadekoBot private readonly Timer commandLogTimer = new Timer() { Interval = 10000 }; private readonly Timer carbonStatusTimer = new Timer() { Interval = 3600000 }; + private static ulong messageCounter = 0; + public static ulong MessageCounter => messageCounter; + static NadekoStats() { } private NadekoStats() @@ -50,6 +53,8 @@ namespace NadekoBot TextChannelsCount = channelsArray.Count(c => c.Type == ChannelType.Text); VoiceChannelsCount = channelsArray.Count() - TextChannelsCount; + NadekoBot.Client.MessageReceived += (s, e) => messageCounter++; + NadekoBot.Client.JoinedServer += (s, e) => { try @@ -131,7 +136,7 @@ namespace NadekoBot public string GetUptimeString() { - var time = (DateTime.Now - Process.GetCurrentProcess().StartTime); + var time = GetUptime(); return time.Days + " days, " + time.Hours + " hours, and " + time.Minutes + " minutes."; } @@ -154,7 +159,7 @@ namespace NadekoBot sb.Append($"`Greeted {ServerGreetCommand.Greeted} times.`"); sb.AppendLine($" `| Playing {songs} songs, ".SnPl(songs) + $"{MusicModule.MusicPlayers.Sum(kvp => kvp.Value.Playlist.Count)} queued.`"); - sb.AppendLine($"`Heap: {Heap(false)}`"); + sb.AppendLine($"`Messages: {messageCounter} ({messageCounter / (double)GetUptime().TotalSeconds:F2}/sec)` `Heap: {Heap(false)}`"); statsCache = sb.ToString(); });