2017-04-13 00:03:03 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Discord.WebSocket;
|
2017-05-06 20:35:31 +02:00
|
|
|
|
using Geekbot.net.Lib.IClients;
|
2017-04-14 21:36:01 +02:00
|
|
|
|
using StackExchange.Redis;
|
2017-04-13 00:03:03 +02:00
|
|
|
|
|
|
|
|
|
namespace Geekbot.net.Lib
|
|
|
|
|
{
|
|
|
|
|
public class StatsRecorder
|
|
|
|
|
{
|
|
|
|
|
|
2017-04-14 21:36:01 +02:00
|
|
|
|
private readonly SocketMessage message;
|
|
|
|
|
private readonly IDatabase redis;
|
2017-04-13 13:22:30 +02:00
|
|
|
|
|
2017-04-18 11:00:38 +02:00
|
|
|
|
public StatsRecorder(SocketMessage message, IRedisClient redisClient)
|
2017-04-13 00:03:03 +02:00
|
|
|
|
{
|
2017-04-13 13:22:30 +02:00
|
|
|
|
this.message = message;
|
2017-04-18 11:00:38 +02:00
|
|
|
|
redis = redisClient.Client;
|
2017-04-13 00:03:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-13 13:22:30 +02:00
|
|
|
|
public async Task UpdateUserRecordAsync()
|
2017-04-13 00:03:03 +02:00
|
|
|
|
{
|
2017-04-14 21:36:01 +02:00
|
|
|
|
var guildId = ((SocketGuildChannel) message.Channel).Guild.Id;
|
|
|
|
|
var key = guildId + "-" + message.Author.Id + "-messages";
|
2017-04-22 23:41:15 +02:00
|
|
|
|
await redis.StringIncrementAsync(key);
|
2017-04-13 00:03:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-13 13:22:30 +02:00
|
|
|
|
public async Task UpdateGuildRecordAsync()
|
2017-04-13 00:03:03 +02:00
|
|
|
|
{
|
2017-04-14 21:36:01 +02:00
|
|
|
|
var guildId = ((SocketGuildChannel) message.Channel).Guild.Id;
|
|
|
|
|
var key = guildId + "-messages";
|
2017-04-22 23:41:15 +02:00
|
|
|
|
await redis.StringIncrementAsync(key);
|
2017-04-13 00:03:03 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|