using Discord.WebSocket;
using Newtonsoft.Json.Linq;
using Noikoio.RegexBot.ConfigItem;
using Npgsql;
using NpgsqlTypes;
using System.Threading.Tasks;
namespace Noikoio.RegexBot.Module.DBCache
{
///
/// Caches information regarding all incoming messages.
/// The function of this feature should be transparent to the user, and thus no configuration is needed.
///
class MessageCache : BotFeature
{
// TODO Something that clears expired cache items
private readonly DatabaseConfig _db;
public override string Name => nameof(MessageCache);
public MessageCache(DiscordSocketClient client) : base(client)
{
_db = RegexBot.Config.Database;
if (_db.Enabled)
{
CreateCacheTables();
client.MessageReceived += Client_MessageReceived;
//client.MessageUpdated += Client_MessageUpdated;
}
else
{
Log("No database storage available.").Wait();
}
}
#region Table setup
const string TableMessage = "cache_messages";
public override Task