diff --git a/src/EllieBot/Bot.cs b/src/EllieBot/Bot.cs index 25cc874..8dd9e1e 100644 --- a/src/EllieBot/Bot.cs +++ b/src/EllieBot/Bot.cs @@ -119,7 +119,6 @@ public sealed class Bot : IBot svcs.AddSingleton<IConfigSeria, YamlSeria>(); svcs.AddSingleton<IMemoryCache, MemoryCache>(new MemoryCache(new MemoryCacheOptions())); svcs.AddSingleton<IBehaviorHandler, BehaviorHandler>(); - svcs.AddSingleton<ILocalization, Localization>(); foreach (var a in _loadedAssemblies) diff --git a/src/EllieBot/Db/Models/GuildConfig.cs b/src/EllieBot/Db/Models/GuildConfig.cs index 3264088..72fcf7b 100644 --- a/src/EllieBot/Db/Models/GuildConfig.cs +++ b/src/EllieBot/Db/Models/GuildConfig.cs @@ -16,7 +16,6 @@ public class GuildFilterConfig public bool FilterWords { get; set; } public HashSet<FilterChannelId> FilterInvitesChannelIds { get; set; } = new(); public HashSet<FilterLinksChannelId> FilterLinksChannelIds { get; set; } = new(); - public HashSet<FilteredWord> FilteredWords { get; set; } = new(); public HashSet<FilterWordsChannelId> FilterWordsChannelIds { get; set; } = new(); } diff --git a/src/EllieBot/Db/Models/filter/FilterChannelId.cs b/src/EllieBot/Db/Models/filter/FilterChannelId.cs index e470473..b08cd04 100644 --- a/src/EllieBot/Db/Models/filter/FilterChannelId.cs +++ b/src/EllieBot/Db/Models/filter/FilterChannelId.cs @@ -8,6 +8,8 @@ public class FilterChannelId [Key] public int Id { get; set; } + public int GuildFilterConfigId { get; set; } + public ulong ChannelId { get; set; } protected bool Equals(FilterChannelId other) diff --git a/src/EllieBot/Db/Models/filter/FilterLinksChannelId.cs b/src/EllieBot/Db/Models/filter/FilterLinksChannelId.cs index e8be32d..472f5cf 100644 --- a/src/EllieBot/Db/Models/filter/FilterLinksChannelId.cs +++ b/src/EllieBot/Db/Models/filter/FilterLinksChannelId.cs @@ -1,10 +1,9 @@ -using System.ComponentModel.DataAnnotations.Schema; - namespace EllieBot.Db.Models; public class FilterLinksChannelId : DbEntity { public ulong ChannelId { get; set; } + public int GuildFilterConfigId { get; set; } protected bool Equals(FilterLinksChannelId other) => ChannelId == other.ChannelId; diff --git a/src/EllieBot/Db/Models/filter/FilterWordsChannelId.cs b/src/EllieBot/Db/Models/filter/FilterWordsChannelId.cs index 71552ae..63bdb30 100644 --- a/src/EllieBot/Db/Models/filter/FilterWordsChannelId.cs +++ b/src/EllieBot/Db/Models/filter/FilterWordsChannelId.cs @@ -1,10 +1,9 @@ #nullable disable -using System.ComponentModel.DataAnnotations.Schema; - namespace EllieBot.Db.Models; public class FilterWordsChannelId : DbEntity { + public int GuildFilterConfigId { get; set; } public ulong ChannelId { get; set; } protected bool Equals(FilterWordsChannelId other) diff --git a/src/EllieBot/Db/Models/filter/FilteredWord.cs b/src/EllieBot/Db/Models/filter/FilteredWord.cs index c06179e..5c20485 100644 --- a/src/EllieBot/Db/Models/filter/FilteredWord.cs +++ b/src/EllieBot/Db/Models/filter/FilteredWord.cs @@ -2,6 +2,7 @@ namespace EllieBot.Db.Models; public class FilteredWord : DbEntity { + public int GuildFilterConfigId { get; set; } public string Word { get; set; } = string.Empty; public override bool Equals(object? obj) => obj is FilteredWord fw && fw.Word == Word; diff --git a/src/EllieBot/Db/Models/xp/ExcludedItem.cs b/src/EllieBot/Db/Models/xp/ExcludedItem.cs index de2c409..e1f7ed9 100644 --- a/src/EllieBot/Db/Models/xp/ExcludedItem.cs +++ b/src/EllieBot/Db/Models/xp/ExcludedItem.cs @@ -2,6 +2,7 @@ public class ExcludedItem : DbEntity { + public int XpSettingsId { get; set; } public ulong ItemId { get; set; } public ExcludedItemType ItemType { get; set; } diff --git a/src/EllieBot/EllieBot.csproj b/src/EllieBot/EllieBot.csproj index 911fa6a..b384cbf 100644 --- a/src/EllieBot/EllieBot.csproj +++ b/src/EllieBot/EllieBot.csproj @@ -112,10 +112,6 @@ <AdditionalFiles Include="strings\responses\responses.en-US.json" /> </ItemGroup> - <ItemGroup> - <Compile Include="Migrations\Sqlite\20250202095042_fk-remove.sql" /> - </ItemGroup> - <ItemGroup> <None Update="data\**\*"> <ExcludeFromSingleFile>true</ExcludeFromSingleFile> diff --git a/src/EllieBot/Migrations/PostgreSql/20250202095110_init.Designer.cs b/src/EllieBot/Migrations/PostgreSql/20250127062816_init.Designer.cs similarity index 99% rename from src/EllieBot/Migrations/PostgreSql/20250202095110_init.Designer.cs rename to src/EllieBot/Migrations/PostgreSql/20250127062816_init.Designer.cs index 5473578..afb4add 100644 --- a/src/EllieBot/Migrations/PostgreSql/20250202095110_init.Designer.cs +++ b/src/EllieBot/Migrations/PostgreSql/20250127062816_init.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace EllieBot.Migrations.PostgreSql { [DbContext(typeof(PostgreSqlContext))] - [Migration("20250202095110_init")] + [Migration("20250127062816_init")] partial class init { /// <inheritdoc /> @@ -85,6 +85,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") .HasColumnType("numeric(20,0)") .HasColumnName("guildid"); @@ -747,6 +751,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") .HasColumnType("numeric(20,0)") .HasColumnName("guildid"); @@ -928,6 +936,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") .HasColumnType("numeric(20,0)") .HasColumnName("guildid"); @@ -1054,7 +1066,6 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnName("guildfilterconfigid"); b.Property<string>("Word") - .IsRequired() .HasColumnType("text") .HasColumnName("word"); @@ -3356,6 +3367,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") .HasColumnType("numeric(20,0)") .HasColumnName("guildid"); diff --git a/src/EllieBot/Migrations/PostgreSql/20250202095110_init.cs b/src/EllieBot/Migrations/PostgreSql/20250127062816_init.cs similarity index 99% rename from src/EllieBot/Migrations/PostgreSql/20250202095110_init.cs rename to src/EllieBot/Migrations/PostgreSql/20250127062816_init.cs index 0800544..0ad8347 100644 --- a/src/EllieBot/Migrations/PostgreSql/20250202095110_init.cs +++ b/src/EllieBot/Migrations/PostgreSql/20250127062816_init.cs @@ -36,6 +36,7 @@ namespace EllieBot.Migrations.PostgreSql { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildconfigid = table.Column<int>(type: "integer", nullable: false), guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), userthreshold = table.Column<int>(type: "integer", nullable: false), seconds = table.Column<int>(type: "integer", nullable: false), @@ -244,6 +245,7 @@ namespace EllieBot.Migrations.PostgreSql { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildconfigid = table.Column<int>(type: "integer", nullable: false), guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), state = table.Column<bool>(type: "boolean", nullable: false), @@ -297,6 +299,7 @@ namespace EllieBot.Migrations.PostgreSql { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildconfigid = table.Column<int>(type: "integer", nullable: false), guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), url = table.Column<string>(type: "text", nullable: true), @@ -1117,6 +1120,7 @@ namespace EllieBot.Migrations.PostgreSql { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + guildconfigid = table.Column<int>(type: "integer", nullable: false), guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), serverexcluded = table.Column<bool>(type: "boolean", nullable: false), dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) @@ -1261,7 +1265,7 @@ namespace EllieBot.Migrations.PostgreSql { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - word = table.Column<string>(type: "text", nullable: false), + word = table.Column<string>(type: "text", nullable: true), guildfilterconfigid = table.Column<int>(type: "integer", nullable: true), dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) }, diff --git a/src/EllieBot/Migrations/PostgreSql/20250202095045_fk-remove.sql b/src/EllieBot/Migrations/PostgreSql/20250202095045_fk-remove.sql deleted file mode 100644 index d2e2269..0000000 --- a/src/EllieBot/Migrations/PostgreSql/20250202095045_fk-remove.sql +++ /dev/null @@ -1,18 +0,0 @@ -START TRANSACTION; -ALTER TABLE xpsettings DROP COLUMN guildconfigid; - -ALTER TABLE feedsub DROP COLUMN guildconfigid; - -ALTER TABLE delmsgoncmdchannel DROP COLUMN guildconfigid; - -ALTER TABLE antiraidsetting DROP COLUMN guildconfigid; - -UPDATE filteredword SET word = '' WHERE word IS NULL; -ALTER TABLE filteredword ALTER COLUMN word SET NOT NULL; -ALTER TABLE filteredword ALTER COLUMN word SET DEFAULT ''; - -INSERT INTO "__EFMigrationsHistory" (migrationid, productversion) -VALUES ('20250202095045_fk-remove', '9.0.1'); - -COMMIT; - diff --git a/src/EllieBot/Migrations/PostgreSql/PostgreSqlContextModelSnapshot.cs b/src/EllieBot/Migrations/PostgreSql/PostgreSqlContextModelSnapshot.cs index 349a2ca..ad0ebcd 100644 --- a/src/EllieBot/Migrations/PostgreSql/PostgreSqlContextModelSnapshot.cs +++ b/src/EllieBot/Migrations/PostgreSql/PostgreSqlContextModelSnapshot.cs @@ -82,6 +82,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") .HasColumnType("numeric(20,0)") .HasColumnName("guildid"); @@ -744,6 +748,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") .HasColumnType("numeric(20,0)") .HasColumnName("guildid"); @@ -925,6 +933,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") .HasColumnType("numeric(20,0)") .HasColumnName("guildid"); @@ -1051,7 +1063,6 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnName("guildfilterconfigid"); b.Property<string>("Word") - .IsRequired() .HasColumnType("text") .HasColumnName("word"); @@ -3353,6 +3364,10 @@ namespace EllieBot.Migrations.PostgreSql .HasColumnType("timestamp without time zone") .HasColumnName("dateadded"); + b.Property<int>("GuildConfigId") + .HasColumnType("integer") + .HasColumnName("guildconfigid"); + b.Property<decimal>("GuildId") .HasColumnType("numeric(20,0)") .HasColumnName("guildid"); diff --git a/src/EllieBot/Migrations/Sqlite/20250202095107_init.Designer.cs b/src/EllieBot/Migrations/Sqlite/20250127062834_init.Designer.cs similarity index 99% rename from src/EllieBot/Migrations/Sqlite/20250202095107_init.Designer.cs rename to src/EllieBot/Migrations/Sqlite/20250127062834_init.Designer.cs index fa30c6a..6e40885 100644 --- a/src/EllieBot/Migrations/Sqlite/20250202095107_init.Designer.cs +++ b/src/EllieBot/Migrations/Sqlite/20250127062834_init.Designer.cs @@ -11,7 +11,7 @@ using EllieBot.Db; namespace EllieBot.Migrations.Sqlite { [DbContext(typeof(SqliteContext))] - [Migration("20250202095107_init")] + [Migration("20250127062834_init")] partial class init { /// <inheritdoc /> @@ -64,6 +64,9 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); @@ -559,6 +562,9 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); @@ -694,6 +700,9 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); @@ -787,7 +796,6 @@ namespace EllieBot.Migrations.Sqlite .HasColumnType("INTEGER"); b.Property<string>("Word") - .IsRequired() .HasColumnType("TEXT"); b.HasKey("Id"); @@ -2497,6 +2505,9 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); diff --git a/src/EllieBot/Migrations/Sqlite/20250202095107_init.cs b/src/EllieBot/Migrations/Sqlite/20250127062834_init.cs similarity index 99% rename from src/EllieBot/Migrations/Sqlite/20250202095107_init.cs rename to src/EllieBot/Migrations/Sqlite/20250127062834_init.cs index d658d2e..b91fdd7 100644 --- a/src/EllieBot/Migrations/Sqlite/20250202095107_init.cs +++ b/src/EllieBot/Migrations/Sqlite/20250127062834_init.cs @@ -35,6 +35,7 @@ namespace EllieBot.Migrations.Sqlite { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), + GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), UserThreshold = table.Column<int>(type: "INTEGER", nullable: false), Seconds = table.Column<int>(type: "INTEGER", nullable: false), @@ -243,6 +244,7 @@ namespace EllieBot.Migrations.Sqlite { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), + GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), State = table.Column<bool>(type: "INTEGER", nullable: false), @@ -296,6 +298,7 @@ namespace EllieBot.Migrations.Sqlite { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), + GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), Url = table.Column<string>(type: "TEXT", nullable: true), @@ -1119,6 +1122,7 @@ namespace EllieBot.Migrations.Sqlite { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), + GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false), GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), ServerExcluded = table.Column<bool>(type: "INTEGER", nullable: false), DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) @@ -1263,7 +1267,7 @@ namespace EllieBot.Migrations.Sqlite { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - Word = table.Column<string>(type: "TEXT", nullable: false), + Word = table.Column<string>(type: "TEXT", nullable: true), GuildFilterConfigId = table.Column<int>(type: "INTEGER", nullable: true), DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) }, diff --git a/src/EllieBot/Migrations/Sqlite/20250202095042_fk-remove.sql b/src/EllieBot/Migrations/Sqlite/20250202095042_fk-remove.sql deleted file mode 100644 index 29db78b..0000000 --- a/src/EllieBot/Migrations/Sqlite/20250202095042_fk-remove.sql +++ /dev/null @@ -1,108 +0,0 @@ -BEGIN TRANSACTION; -CREATE TABLE "ef_temp_XpSettings" ( - "Id" INTEGER NOT NULL CONSTRAINT "PK_XpSettings" PRIMARY KEY AUTOINCREMENT, - "DateAdded" TEXT NULL, - "GuildId" INTEGER NOT NULL, - "ServerExcluded" INTEGER NOT NULL -); - -INSERT INTO "ef_temp_XpSettings" ("Id", "DateAdded", "GuildId", "ServerExcluded") -SELECT "Id", "DateAdded", "GuildId", "ServerExcluded" -FROM "XpSettings"; - -CREATE TABLE "ef_temp_FeedSub" ( - "Id" INTEGER NOT NULL CONSTRAINT "PK_FeedSub" PRIMARY KEY AUTOINCREMENT, - "ChannelId" INTEGER NOT NULL, - "DateAdded" TEXT NULL, - "GuildId" INTEGER NOT NULL, - "Message" TEXT NULL, - "Url" TEXT NULL -); - -INSERT INTO "ef_temp_FeedSub" ("Id", "ChannelId", "DateAdded", "GuildId", "Message", "Url") -SELECT "Id", "ChannelId", "DateAdded", "GuildId", "Message", "Url" -FROM "FeedSub"; - -CREATE TABLE "ef_temp_DelMsgOnCmdChannel" ( - "Id" INTEGER NOT NULL CONSTRAINT "PK_DelMsgOnCmdChannel" PRIMARY KEY AUTOINCREMENT, - "ChannelId" INTEGER NOT NULL, - "DateAdded" TEXT NULL, - "GuildId" INTEGER NOT NULL, - "State" INTEGER NOT NULL -); - -INSERT INTO "ef_temp_DelMsgOnCmdChannel" ("Id", "ChannelId", "DateAdded", "GuildId", "State") -SELECT "Id", "ChannelId", "DateAdded", "GuildId", "State" -FROM "DelMsgOnCmdChannel"; - -CREATE TABLE "ef_temp_AntiRaidSetting" ( - "Id" INTEGER NOT NULL CONSTRAINT "PK_AntiRaidSetting" PRIMARY KEY AUTOINCREMENT, - "Action" INTEGER NOT NULL, - "DateAdded" TEXT NULL, - "GuildId" INTEGER NOT NULL, - "PunishDuration" INTEGER NOT NULL, - "Seconds" INTEGER NOT NULL, - "UserThreshold" INTEGER NOT NULL -); - -INSERT INTO "ef_temp_AntiRaidSetting" ("Id", "Action", "DateAdded", "GuildId", "PunishDuration", "Seconds", "UserThreshold") -SELECT "Id", "Action", "DateAdded", "GuildId", "PunishDuration", "Seconds", "UserThreshold" -FROM "AntiRaidSetting"; - -CREATE TABLE "ef_temp_FilteredWord" ( - "Id" INTEGER NOT NULL CONSTRAINT "PK_FilteredWord" PRIMARY KEY AUTOINCREMENT, - "DateAdded" TEXT NULL, - "GuildFilterConfigId" INTEGER NULL, - "Word" TEXT NOT NULL, - CONSTRAINT "FK_FilteredWord_GuildFilterConfig_GuildFilterConfigId" FOREIGN KEY ("GuildFilterConfigId") REFERENCES "GuildFilterConfig" ("Id") -); - -INSERT INTO "ef_temp_FilteredWord" ("Id", "DateAdded", "GuildFilterConfigId", "Word") -SELECT "Id", "DateAdded", "GuildFilterConfigId", IFNULL("Word", '') -FROM "FilteredWord"; - -COMMIT; - -PRAGMA foreign_keys = 0; - -BEGIN TRANSACTION; -DROP TABLE "XpSettings"; - -ALTER TABLE "ef_temp_XpSettings" RENAME TO "XpSettings"; - -DROP TABLE "FeedSub"; - -ALTER TABLE "ef_temp_FeedSub" RENAME TO "FeedSub"; - -DROP TABLE "DelMsgOnCmdChannel"; - -ALTER TABLE "ef_temp_DelMsgOnCmdChannel" RENAME TO "DelMsgOnCmdChannel"; - -DROP TABLE "AntiRaidSetting"; - -ALTER TABLE "ef_temp_AntiRaidSetting" RENAME TO "AntiRaidSetting"; - -DROP TABLE "FilteredWord"; - -ALTER TABLE "ef_temp_FilteredWord" RENAME TO "FilteredWord"; - -COMMIT; - -PRAGMA foreign_keys = 1; - -BEGIN TRANSACTION; -CREATE UNIQUE INDEX "IX_XpSettings_GuildId" ON "XpSettings" ("GuildId"); - -CREATE UNIQUE INDEX "IX_FeedSub_GuildId_Url" ON "FeedSub" ("GuildId", "Url"); - -CREATE UNIQUE INDEX "IX_DelMsgOnCmdChannel_GuildId_ChannelId" ON "DelMsgOnCmdChannel" ("GuildId", "ChannelId"); - -CREATE UNIQUE INDEX "IX_AntiRaidSetting_GuildId" ON "AntiRaidSetting" ("GuildId"); - -CREATE INDEX "IX_FilteredWord_GuildFilterConfigId" ON "FilteredWord" ("GuildFilterConfigId"); - -COMMIT; - -INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") -VALUES ('20250202095042_fk-remove', '9.0.1'); - diff --git a/src/EllieBot/Migrations/Sqlite/SqliteContextModelSnapshot.cs b/src/EllieBot/Migrations/Sqlite/SqliteContextModelSnapshot.cs index 55e5411..457aec3 100644 --- a/src/EllieBot/Migrations/Sqlite/SqliteContextModelSnapshot.cs +++ b/src/EllieBot/Migrations/Sqlite/SqliteContextModelSnapshot.cs @@ -61,6 +61,9 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); @@ -556,6 +559,9 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); @@ -691,6 +697,9 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); @@ -784,7 +793,6 @@ namespace EllieBot.Migrations.Sqlite .HasColumnType("INTEGER"); b.Property<string>("Word") - .IsRequired() .HasColumnType("TEXT"); b.HasKey("Id"); @@ -2494,6 +2502,9 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); + b.Property<int>("GuildConfigId") + .HasColumnType("INTEGER"); + b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); diff --git a/src/EllieBot/Modules/Expressions/EllieExpressionsService.cs b/src/EllieBot/Modules/Expressions/EllieExpressionsService.cs index 96d97e6..72d02f7 100644 --- a/src/EllieBot/Modules/Expressions/EllieExpressionsService.cs +++ b/src/EllieBot/Modules/Expressions/EllieExpressionsService.cs @@ -11,7 +11,7 @@ using YamlDotNet.Serialization.NamingConventions; namespace EllieBot.Modules.EllieExpressions; -public sealed class EllieExpressionsService : IExecOnMessage, IReadyExecutor +public sealed class EllieExpressionsService : IExecOnMessage, IReadyExecutor, IEService { private const string MENTION_PH = "%bot.mention%"; @@ -63,18 +63,14 @@ public sealed class EllieExpressionsService : IExecOnMessage, IReadyExecutor private readonly DiscordSocketClient _client; - // private readonly PermissionService _perms; - // private readonly GlobalPermissionService _gperm; - // private readonly CmdCdService _cmdCds; private readonly IPermissionChecker _permChecker; private readonly IBotStrings _strings; - private readonly IBot _bot; private readonly IPubSub _pubSub; private readonly IMessageSenderService _sender; private readonly IReplacementService _repSvc; private readonly Random _rng; - private bool ready; + private bool _isReady; private ConcurrentHashSet<ulong> _disabledGlobalExpressionGuilds; private readonly PermissionService _pc; private readonly ShardData _shardData; @@ -94,7 +90,6 @@ public sealed class EllieExpressionsService : IExecOnMessage, IReadyExecutor _db = db; _client = client; _strings = strings; - _bot = bot; _pubSub = pubSub; _sender = sender; _repSvc = repSvc; @@ -155,12 +150,12 @@ public sealed class EllieExpressionsService : IExecOnMessage, IReadyExecutor globalExpressions = globalItems; } - ready = true; + _isReady = true; } private EllieExpression TryGetExpression(IUserMessage umsg) { - if (!ready) + if (!_isReady) return null; if (umsg.Channel is not SocketTextChannel channel) @@ -178,9 +173,7 @@ public sealed class EllieExpressionsService : IExecOnMessage, IReadyExecutor if (_disabledGlobalExpressionGuilds.Contains(channel.Guild.Id)) return null; - var localGrs = globalExpressions; - - return MatchExpressions(content, localGrs); + return MatchExpressions(content, globalExpressions); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/EllieBot/_common/Impl/Localization.cs b/src/EllieBot/_common/Impl/Localization.cs index dcde99d..32d68be 100644 --- a/src/EllieBot/_common/Impl/Localization.cs +++ b/src/EllieBot/_common/Impl/Localization.cs @@ -1,13 +1,12 @@ #nullable disable using LinqToDB.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db.Models; using Newtonsoft.Json; using System.Globalization; namespace EllieBot.Services; -public class Localization : ILocalization, IReadyExecutor +public class Localization : ILocalization, IReadyExecutor, IEService { private static readonly Dictionary<string, CommandData> _commandData = JsonConvert.DeserializeObject<Dictionary<string, CommandData>>( diff --git a/src/EllieBot/_common/Services/Impl/BlacklistService.cs b/src/EllieBot/_common/Services/Impl/BlacklistService.cs index 2980158..73b0525 100644 --- a/src/EllieBot/_common/Services/Impl/BlacklistService.cs +++ b/src/EllieBot/_common/Services/Impl/BlacklistService.cs @@ -7,7 +7,7 @@ using System.Collections.Frozen; namespace EllieBot.Modules.Permissions.Services; -public sealed class BlacklistService : IExecOnMessage, IReadyExecutor +public sealed class BlacklistService : IExecOnMessage, IReadyExecutor, IEService { public int Priority => int.MaxValue;