From 5c972997c0ce34e16ab4e211734a0b78bfd5c9a9 Mon Sep 17 00:00:00 2001 From: Noikoio Date: Sun, 29 Oct 2017 20:04:57 -0700 Subject: [PATCH] Added DBCache Currently incomplete. This feature will maintain a cache of entities in a database to be used by upcoming features and possible external utilities to be created in the future. --- Feature/DBCache/DBCache.cs | 74 ++++++++++++++++++++++++++++++++++++++ RegexBot.cs | 3 +- RegexBot.csproj | 1 + 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 Feature/DBCache/DBCache.cs diff --git a/Feature/DBCache/DBCache.cs b/Feature/DBCache/DBCache.cs new file mode 100644 index 0000000..ec3dd94 --- /dev/null +++ b/Feature/DBCache/DBCache.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Discord.WebSocket; +using Newtonsoft.Json.Linq; + +namespace Noikoio.RegexBot.Feature.DBCache +{ + /// + /// Caches information regarding all incoming messages and all known guilds, channels, and users. + /// The function of this feature should be transparent to the user, and thus no configuration is needed. + /// + class DBCache : BotFeature + { + public override string Name => "Database cache"; + + public DBCache(DiscordSocketClient client) : base(client) + { + client.GuildAvailable += Client_GuildAvailable; + client.GuildUpdated += Client_GuildUpdated; + client.GuildMemberUpdated += Client_GuildMemberUpdated; + + client.MessageReceived += Client_MessageReceived; + client.MessageUpdated += Client_MessageUpdated; + } + + public override Task ProcessConfiguration(JToken configSection) => Task.FromResult(null); + + #region Guild and user cache + /* Note: + * We save information per guild in their own schemas named "g_NUM", where NUM is the Guild ID. + * + * The creation of these schemas is handled within here, but we're possibly facing a short delay + * in the event that other events that we're listening for come in without a schema having been + * created yet in which to put them in. + * Got to figure that out. + */ + + // Guild information has changed + private Task Client_GuildUpdated(SocketGuild arg1, SocketGuild arg2) + { + throw new NotImplementedException(); + } + + // Single guild member information has changed + private Task Client_GuildMemberUpdated(SocketGuildUser arg1, SocketGuildUser arg2) + { + // which is old and which is new? + throw new NotImplementedException(); + } + + // All member data in a guild has become known + private Task Client_GuildAvailable(SocketGuild arg) + { + throw new NotImplementedException(); + } + #endregion + + #region Message cache + private Task Client_MessageUpdated(Discord.Cacheable arg1, SocketMessage arg2, ISocketMessageChannel arg3) + { + throw new NotImplementedException(); + } + + private Task Client_MessageReceived(SocketMessage arg) + { + throw new NotImplementedException(); + } + #endregion + + + } +} diff --git a/RegexBot.cs b/RegexBot.cs index 18d2241..c68d0e2 100644 --- a/RegexBot.cs +++ b/RegexBot.cs @@ -47,7 +47,8 @@ namespace Noikoio.RegexBot { new Feature.AutoMod.AutoMod(_client), new Feature.ModTools.ModTools(_client), - new Feature.AutoRespond.AutoRespond(_client) + new Feature.AutoRespond.AutoRespond(_client), + new Feature.DBCache.DBCache(_client) }; var dlog = Logger.GetLogger("Discord.Net"); _client.Log += async (arg) => diff --git a/RegexBot.csproj b/RegexBot.csproj index 5d36a7d..8ceb30a 100644 --- a/RegexBot.csproj +++ b/RegexBot.csproj @@ -17,6 +17,7 @@ +