Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d22bf2ccbe | ||
|
d75dc4a2fb | ||
|
06740fc9ab | ||
|
cb0d4111d6 |
@ -1,7 +1,7 @@
|
||||
![img](https://ci.appveyor.com/api/projects/status/gmu6b3ltc80hr3k9?svg=true)
|
||||
[![Discord](https://discordapp.com/api/guilds/117523346618318850/widget.png)](https://discord.gg/nadekobot)
|
||||
[![Documentation Status](https://readthedocs.org/projects/nadekobot/badge/?version=latest)](http://nadekobot.readthedocs.io/en/latest/?badge=latest)
|
||||
[![nadeko0](https://cdn.discordapp.com/attachments/266240393639755778/281920716809699328/part1.png)](http://nadekobot.xyz)
|
||||
[![nadeko0](https://cdn.discordapp.com/attachments/266240393639755778/281920716809699328/part1.png)](https://nadekobot.me)
|
||||
[![nadeko1](https://cdn.discordapp.com/attachments/266240393639755778/281920134967328768/part2.png)](https://discordapp.com/oauth2/authorize?client_id=170254782546575360&scope=bot&permissions=66186303)
|
||||
[![nadeko2](https://cdn.discordapp.com/attachments/266240393639755778/281920161311883264/part3.png)](http://nadekobot.readthedocs.io/en/latest/Commands%20List/)
|
||||
|
||||
|
@ -8,6 +8,9 @@ using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Cryptography;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace NadekoBot.Services.Impl
|
||||
{
|
||||
@ -34,6 +37,7 @@ namespace NadekoBot.Services.Impl
|
||||
public long CommandsRan => Interlocked.Read(ref _commandsRan);
|
||||
|
||||
private Timer carbonitexTimer { get; }
|
||||
private Timer _dataTimer { get; }
|
||||
|
||||
public StatsService(DiscordShardedClient client, CommandHandler cmdHandler)
|
||||
{
|
||||
@ -114,6 +118,14 @@ namespace NadekoBot.Services.Impl
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
var platform = "other";
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
platform = "linux";
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
platform = "osx";
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
platform = "windows";
|
||||
|
||||
carbonitexTimer = new Timer(async (state) =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.CarbonKey))
|
||||
@ -139,6 +151,32 @@ namespace NadekoBot.Services.Impl
|
||||
// ignored
|
||||
}
|
||||
}, 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(NadekoBot.Credentials.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()
|
||||
|
Loading…
Reference in New Issue
Block a user