Reworked Database, using hashtables now (mostly), ability to change game, several small improvents

This commit is contained in:
Runebaas 2017-09-27 22:48:09 +02:00
parent 7308e5257a
commit 29c181ddda
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
13 changed files with 264 additions and 178 deletions

View file

@ -0,0 +1,24 @@
using Serilog;
using System.Linq;
namespace Geekbot.net.Lib
{
public class LoggerFactory
{
public static ILogger createLogger(string[] args)
{
var loggerCreation = new LoggerConfiguration()
.WriteTo.LiterateConsole()
.WriteTo.RollingFile("Logs/geekbot-{Date}.txt", shared: true);
if (args.Length != 0 && args.Contains("--verbose"))
{
loggerCreation.MinimumLevel.Verbose();
}
else
{
loggerCreation.MinimumLevel.Information();
}
return loggerCreation.CreateLogger();
}
}
}

View file

@ -19,7 +19,7 @@ namespace Geekbot.net.Lib.Media
checkEmImageArray = rawCheckEmPics.Split("\n");
totalCheckEmImages = checkEmImageArray.Length;
this.rnd = rnd;
logger.Information($"[Geekbot] [CheckEm] Loaded {totalCheckEmImages} CheckEm Images");
logger.Verbose($"[Geekbot] [CheckEm] Loaded {totalCheckEmImages} CheckEm Images");
}
else
{

View file

@ -19,7 +19,7 @@ namespace Geekbot.net.Lib.Media
fortuneArray = rawFortunes.Split("%");
totalFortunes = fortuneArray.Length;
this.rnd = rnd;
logger.Information($"[Geekbot] [Fortunes] Loaded {totalFortunes} Fortunes");
logger.Verbose($"[Geekbot] [Fortunes] Loaded {totalFortunes} Fortunes");
}
else
{

View file

@ -19,7 +19,7 @@ namespace Geekbot.net.Lib.Media
PandaArray = rawFortunes.Split("\n");
totalPandas = PandaArray.Length;
this.rnd = rnd;
logger.Information($"[Geekbot] [Pandas] Loaded {totalPandas} Panda Images");
logger.Verbose($"[Geekbot] [Pandas] Loaded {totalPandas} Panda Images");
}
else
{

View file

@ -1,32 +0,0 @@
using System.Threading.Tasks;
using Discord.WebSocket;
using StackExchange.Redis;
namespace Geekbot.net.Lib
{
public class StatsRecorder
{
private readonly SocketMessage message;
private readonly IDatabase redis;
public StatsRecorder(SocketMessage message, IDatabase redis)
{
this.message = message;
this.redis = redis;
}
public async Task UpdateUserRecordAsync()
{
var guildId = ((SocketGuildChannel) message.Channel).Guild.Id;
var key = guildId + "-" + message.Author.Id + "-messages";
await redis.StringIncrementAsync(key);
}
public async Task UpdateGuildRecordAsync()
{
var guildId = ((SocketGuildChannel) message.Channel).Guild.Id;
var key = guildId + "-messages";
await redis.StringIncrementAsync(key);
}
}
}