Reworked Database, using hashtables now (mostly), ability to change game, several small improvents
This commit is contained in:
parent
7308e5257a
commit
29c181ddda
13 changed files with 264 additions and 178 deletions
24
Geekbot.net/Lib/LoggerFactory.cs
Normal file
24
Geekbot.net/Lib/LoggerFactory.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue