discord-bot/CompatBot/Database/Providers
2020-08-01 16:23:50 +05:00
..
AmdDriverVersionProvider.cs show unknown amd driver versions 2020-02-20 02:23:30 +05:00
ContentFilter.cs fix filters 2020-07-03 13:55:34 +05:00
DisabledCommandsProvider.cs refactor to use using statement whenever it makes sense 2019-11-25 18:07:01 +05:00
InviteWhitelistProvider.cs ah yes, I'm very smart 2020-02-05 23:33:40 +05:00
ModProvider.cs sync mod members to bot sudoers 2020-04-02 20:41:24 +05:00
readme.md code documentation, part 2 2019-08-26 20:24:06 +05:00
ScrapeStateProvider.cs refactor to use using statement whenever it makes sense 2019-11-25 18:07:01 +05:00
SqlConfiguration.cs unconfuse resharper 2020-05-01 14:32:32 +05:00
StatsStorage.cs refactor to use using statement whenever it makes sense 2019-11-25 18:07:01 +05:00
SyscallInfoProvider.cs remove module information for syscall stats 2020-03-21 18:25:14 +05:00
ThumbnailProvider.cs limit in-memory caching duration times 2020-08-01 16:23:50 +05:00

Data Providers

These classes should ease the data access and manipulation. If no special consideration is required, you should use database access directly.

AmdDriverVersionProvider

This class builds and keeps the AMD driver version mappings for Vulkan and OpenGL using GPUOpen project as a source.

AMD has many gotchas with their driver versioning, included, but not limited to:

  • existing versioning information goes only as far back as 18.1.1 release
  • OpenGL driver version may differ from actual driver version
    • major part (m.x.y.z) seems to be following the Windows Driver versioning scheme
    • build part (x.y.z.b) may vary depending on different driver package (desktop vs mobile vs minor re-releases)
  • Vulkan driver versioning is completely separate and may span several driver releases

ContentFilter

This class implements actual content filter using the pre-defined filter descriptions.

As you can probably guess, simply iterating over each filter trigger is not gonna cut it if you have more than 3 filters and a lot of text to moderate. This is where Aho-Corasick algorithm comes into play. It allows for linear complexity over the filtered text length.

On bot start up and every change to the filter list, this provider will reconstruct the Aho-Corasick state machine that is used for content filtering. As an implementation detail, we construct one state machine per filter context (Discord messages or log file).

The idea here is to feed the state machine with the text we want to check. It will invoke the callback on any trigger match, where we can decide if the filter should be applied or not.

As a convenience we have a static methods that will wrap all the details inside, and will perform all the required actions when necessary.

DisabledCommandsProvider

This provider wraps the complexity of bot command framework enumeration in case of a wildcard command matching, and also for synchronization of in-memory hash map and persistent list in the database.

InviteWhitelistProvider

This is mostly needed for maintenance of expired invite codes.

ModProvider

This is mostly a legacy provider for managing the bot roles.

ScrapeStateProvider

This provider wraps up the logic of refreshing the crawler state for different PSN categories, thumbnail caches, etc.

StatsStorage

Contains logic for serialization and deserialization of in-memory stat tracking. One fun part about serialization is that it is using reflection to access non-public member of the cache class to get the actual data.

SyscallInfoProvider

This is mostly needed to wrap up the complexity of persisting the function call data gathered from the logs, as it must be aware of already existing data to insertion of non-unique keys.

ThumbnailProvider

This one will:

  • look up thumbnail image from multiple sources
  • check if it's current
  • check if it can be embedded by Discord (it requires a proper file extension)
    • re-upload it to a private channel for persistent caching if needed
  • update the associated tables in the database

And at the end it will return the readily usable URL.