Update StatsService.cs
This commit is contained in:
parent
cb0d4111d6
commit
06740fc9ab
@ -8,6 +8,8 @@ using System.Linq;
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace NadekoBot.Services.Impl
|
namespace NadekoBot.Services.Impl
|
||||||
{
|
{
|
||||||
@ -34,6 +36,7 @@ namespace NadekoBot.Services.Impl
|
|||||||
public long CommandsRan => Interlocked.Read(ref _commandsRan);
|
public long CommandsRan => Interlocked.Read(ref _commandsRan);
|
||||||
|
|
||||||
private Timer carbonitexTimer { get; }
|
private Timer carbonitexTimer { get; }
|
||||||
|
private Timer _dataTimer { get; }
|
||||||
|
|
||||||
public StatsService(DiscordShardedClient client, CommandHandler cmdHandler)
|
public StatsService(DiscordShardedClient client, CommandHandler cmdHandler)
|
||||||
{
|
{
|
||||||
@ -139,6 +142,32 @@ namespace NadekoBot.Services.Impl
|
|||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
}, null, TimeSpan.FromHours(1), TimeSpan.FromHours(1));
|
}, null, TimeSpan.FromHours(1), TimeSpan.FromHours(1));
|
||||||
|
|
||||||
|
_dataTimer = new Timer(async (state) =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var http = new HttpClient())
|
||||||
|
{
|
||||||
|
using (var content = new FormUrlEncodedContent(
|
||||||
|
new Dictionary<string, string> {
|
||||||
|
{ "id", string.Concat(MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(_creds.ClientId.ToString())).Select(x => x.ToString("X2"))) },
|
||||||
|
{ "guildCount", _client.GetGuildCount().ToString() },
|
||||||
|
{ "version", BotVersion },
|
||||||
|
{ "platform", platform }}))
|
||||||
|
{
|
||||||
|
content.Headers.Clear();
|
||||||
|
content.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
|
||||||
|
await http.PostAsync("https://selfstats.nadekobot.me/", content).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
}, null, TimeSpan.FromSeconds(1), TimeSpan.FromHours(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
|
Loading…
Reference in New Issue
Block a user