Compare commits

...

4 Commits
1.4 ... dev

Author SHA1 Message Date
Master Kwoth
d22bf2ccbe Update StatsService.cs 2017-07-12 16:14:18 +02:00
Master Kwoth
d75dc4a2fb Update StatsService.cs 2017-07-12 16:11:18 +02:00
Master Kwoth
06740fc9ab Update StatsService.cs 2017-07-12 16:03:33 +02:00
Master Kwoth
cb0d4111d6 Update README.md 2017-06-25 07:03:54 +02:00
2 changed files with 40 additions and 2 deletions

View File

@ -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/)

View File

@ -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()