diff --git a/src/EllieBot/Db/Models/filter/FilteredWord.cs b/src/EllieBot/Db/Models/filter/FilteredWord.cs index b12a69e..fe3f98e 100644 --- a/src/EllieBot/Db/Models/filter/FilteredWord.cs +++ b/src/EllieBot/Db/Models/filter/FilteredWord.cs @@ -7,5 +7,5 @@ public class FilteredWord : DbEntity public override bool Equals(object? obj) => obj is FilteredWord fw && fw.Word == Word; - public override int GetHashCode() => Word.GetHashCode(); + public override int GetHashCode() => Word?.GetHashCode() ?? 0; } \ No newline at end of file diff --git a/src/EllieBot/EllieBot.csproj b/src/EllieBot/EllieBot.csproj index b384cbf..918638e 100644 --- a/src/EllieBot/EllieBot.csproj +++ b/src/EllieBot/EllieBot.csproj @@ -1,159 +1,163 @@ <Project Sdk="Microsoft.NET.Sdk"> - <PropertyGroup> - <TargetFramework>net8.0</TargetFramework> - <Nullable>enable</Nullable> - <ImplicitUsings>true</ImplicitUsings> - <SatelliteResourceLanguages>en</SatelliteResourceLanguages> - <Version>5.3.9</Version> + <PropertyGroup> + <TargetFramework>net8.0</TargetFramework> + <Nullable>enable</Nullable> + <ImplicitUsings>true</ImplicitUsings> + <SatelliteResourceLanguages>en</SatelliteResourceLanguages> + <Version>5.3.9</Version> - <!-- Output/build --> - <RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> - <OutputType>exe</OutputType> - <ApplicationIcon>ellie_icon.ico</ApplicationIcon> + <!-- Output/build --> + <RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> + <OutputType>exe</OutputType> + <ApplicationIcon>ellie_icon.ico</ApplicationIcon> - <!-- Analysis/Warnings --> - <!-- <AnalysisMode>Recommended</AnalysisMode>--> - <!-- <AnalysisModeGlobalization>None</AnalysisModeGlobalization>--> - <NoWarn>CS1066;CS8981</NoWarn> + <!-- Analysis/Warnings --> + <!-- <AnalysisMode>Recommended</AnalysisMode>--> + <!-- <AnalysisModeGlobalization>None</AnalysisModeGlobalization>--> + <NoWarn>CS1066;CS8981</NoWarn> - <!-- Profile-guided optimization --> - <TieredPGO>true</TieredPGO> - <DebugType>embedded</DebugType> + <!-- Profile-guided optimization --> + <TieredPGO>true</TieredPGO> + <DebugType>embedded</DebugType> </PropertyGroup> - <ItemGroup> - <PackageReference Include="AngleSharp" Version="1.2.0"> - <PrivateAssets>all</PrivateAssets> - <Publish>True</Publish> - </PackageReference> - <PackageReference Include="CodeHollow.FeedReader" Version="1.2.6" /> - <PackageReference Include="CommandLineParser" Version="2.9.1" /> - <PackageReference Include="Discord.Net" Version="3.17.1" /> - <PackageReference Include="CoreCLR-NCalc" Version="3.1.253" /> - <PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138" /> - <PackageReference Include="Google.Apis.YouTube.v3" Version="1.68.0.3653" /> - <PackageReference Include="Google.Apis.Customsearch.v1" Version="1.49.0.2084" /> + <ItemGroup> + <PackageReference Include="AngleSharp" Version="1.2.0"> + <PrivateAssets>all</PrivateAssets> + <Publish>True</Publish> + </PackageReference> + <PackageReference Include="CodeHollow.FeedReader" Version="1.2.6"/> + <PackageReference Include="CommandLineParser" Version="2.9.1"/> + <PackageReference Include="Discord.Net" Version="3.17.1" /> + <PackageReference Include="CoreCLR-NCalc" Version="3.1.253" /> + <PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138"/> + <PackageReference Include="Google.Apis.YouTube.v3" Version="1.68.0.3653" /> + <PackageReference Include="Google.Apis.Customsearch.v1" Version="1.49.0.2084"/> + + <PackageReference Include="Google.Protobuf" Version="3.29.3" /> + <PackageReference Include="Grpc" Version="2.46.6" /> + <PackageReference Include="Grpc.Net.Client" Version="2.67.0" /> + <PackageReference Include="Grpc.Tools" Version="2.69.0" PrivateAssets="All" /> + + <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.8.0" /> - <PackageReference Include="Google.Protobuf" Version="3.29.3" /> - <PackageReference Include="Grpc" Version="2.46.6" /> - <PackageReference Include="Grpc.Net.Client" Version="2.67.0" /> - <PackageReference Include="Grpc.Tools" Version="2.69.0" PrivateAssets="All" /> + <PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.1" /> + <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.1" /> + <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.1" /> - <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.8.0" /> + <PackageReference Include="MorseCode.ITask" Version="2.0.3"/> + <PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0"/> - <PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.1" /> - <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.1" /> - <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.1" /> + <!-- DI --> + <!-- <PackageReference Include="Ninject" Version="3.3.6"/>--> + <!-- <PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0"/>--> + <!-- <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />--> + <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.1" /> + <PackageReference Include="DryIoc.dll" Version="5.4.3"/> + <!-- <PackageReference Include="Scrutor" Version="4.2.0" />--> - <PackageReference Include="MorseCode.ITask" Version="2.0.3" /> - <PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" /> + <PackageReference Include="Microsoft.Extensions.Http" Version="9.0.1" /> + <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.1" /> + <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.1" /> + <PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2"/> + <PackageReference Include="Newtonsoft.Json" Version="13.0.3"/> + <PackageReference Include="NonBlocking" Version="2.1.2"/> + <PackageReference Include="OneOf" Version="3.0.271" /> + <PackageReference Include="OneOf.SourceGenerator" Version="3.0.271" /> + <PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" /> + <PackageReference Include="Serilog.Sinks.Seq" Version="9.0.0" /> - <!-- DI --> - <!-- <PackageReference Include="Ninject" Version="3.3.6"/>--> - <!-- <PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0"/>--> - <!-- <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />--> - <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.1" /> - <PackageReference Include="DryIoc.dll" Version="5.4.3" /> - <!-- <PackageReference Include="Scrutor" Version="4.2.0" />--> + <PackageReference Include="SixLabors.Fonts" Version="2.1.0" /> + <PackageReference Include="SixLabors.ImageSharp" Version="3.1.6" /> + <PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.5" /> + <PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0009"/> + <PackageReference Include="StackExchange.Redis" Version="2.8.24" /> + <PackageReference Include="YamlDotNet" Version="15.1.6" /> + <PackageReference Include="SharpToken" Version="2.0.3"/> - <PackageReference Include="Microsoft.Extensions.Http" Version="9.0.1" /> - <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.1" /> - <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.1" /> - <PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2" /> - <PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> - <PackageReference Include="NonBlocking" Version="2.1.2" /> - <PackageReference Include="OneOf" Version="3.0.271" /> - <PackageReference Include="OneOf.SourceGenerator" Version="3.0.271" /> - <PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" /> - <PackageReference Include="Serilog.Sinks.Seq" Version="9.0.0" /> - - <PackageReference Include="SixLabors.Fonts" Version="2.1.0" /> - <PackageReference Include="SixLabors.ImageSharp" Version="3.1.6" /> - <PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.5" /> - <PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0009" /> - <PackageReference Include="StackExchange.Redis" Version="2.8.24" /> - <PackageReference Include="YamlDotNet" Version="15.1.6" /> - <PackageReference Include="SharpToken" Version="2.0.3" /> - - <PackageReference Include="JetBrains.Annotations" Version="2024.3.0" /> + <PackageReference Include="JetBrains.Annotations" Version="2024.3.0" /> - <!-- Db-related packages --> - <PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" /> - <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.1"> - <PrivateAssets>all</PrivateAssets> - <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> - </PackageReference> + <!-- Db-related packages --> + <PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" /> + <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.1"> + <PrivateAssets>all</PrivateAssets> + <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> + </PackageReference> - <PackageReference Include="linq2db.EntityFrameworkCore" Version="9.0.0" /> + <PackageReference Include="linq2db.EntityFrameworkCore" Version="9.0.0" /> - <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.1" /> - <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" /> + <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.1" /> + <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" /> - <PackageReference Include="EFCore.NamingConventions" Version="9.0.0" /> + <PackageReference Include="EFCore.NamingConventions" Version="9.0.0" /> - <!-- Used by stream notifications --> - <PackageReference Include="TwitchLib.Api" Version="3.9.0" /> + <!-- Used by stream notifications --> + <PackageReference Include="TwitchLib.Api" Version="3.9.0" /> - <!-- sqlselectcsv and stock --> - <PackageReference Include="CsvHelper" Version="33.0.1" /> + <!-- sqlselectcsv and stock --> + <PackageReference Include="CsvHelper" Version="33.0.1" /> - </ItemGroup> - - <ItemGroup> - <ProjectReference Include="..\EllieBot.GrpcApiBase\EllieBot.GrpcApiBase.csproj" /> - <ProjectReference Include="..\Ellie.Marmalade\Ellie.Marmalade.csproj" /> - <ProjectReference Include="..\EllieBot.Voice\EllieBot.Voice.csproj" /> - <ProjectReference Include="..\EllieBot.Generators\EllieBot.Generators.csproj" OutputItemType="Analyzer" /> </ItemGroup> <ItemGroup> - <AdditionalFiles Include="strings\responses\responses.en-US.json" /> + <ProjectReference Include="..\EllieBot.GrpcApiBase\EllieBot.GrpcApiBase.csproj"/> + <ProjectReference Include="..\Ellie.Marmalade\Ellie.Marmalade.csproj"/> + <ProjectReference Include="..\EllieBot.Voice\EllieBot.Voice.csproj"/> + <ProjectReference Include="..\EllieBot.Generators\EllieBot.Generators.csproj" OutputItemType="Analyzer"/> </ItemGroup> <ItemGroup> - <None Update="data\**\*"> - <ExcludeFromSingleFile>true</ExcludeFromSingleFile> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </None> - <None Update="creds.yml"> - <ExcludeFromSingleFile>true</ExcludeFromSingleFile> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </None> - <None Update="Migrations/**/*.sql"> - <ExcludeFromSingleFile>true</ExcludeFromSingleFile> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </None> - <None Update="strings/**"> - <ExcludeFromSingleFile>true</ExcludeFromSingleFile> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </None> - <None Update="creds_example.yml"> - <ExcludeFromSingleFile>true</ExcludeFromSingleFile> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </None> - <None Update="strings\aliases.yml"> - <ExcludeFromSingleFile>true</ExcludeFromSingleFile> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </None> - + <AdditionalFiles Include="strings\responses\responses.en-US.json"/> </ItemGroup> - + <ItemGroup> - <Protobuf Include="..\EllieBot.Coordinator\Protos\coordinator.proto"> - <Link>_common\CoordinatorProtos\coordinator.proto</Link> + <None Update="data\**\*"> + <ExcludeFromSingleFile>true</ExcludeFromSingleFile> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Update="strings/**"> + <ExcludeFromSingleFile>true</ExcludeFromSingleFile> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </None> + <None Update="creds.yml"> + <ExcludeFromSingleFile>true</ExcludeFromSingleFile> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </None> + <None Update="Migrations/**/*.sql"> + <ExcludeFromSingleFile>true</ExcludeFromSingleFile> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </None> + <None Update="creds_example.yml"> + <ExcludeFromSingleFile>true</ExcludeFromSingleFile> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </None> + <None Update="strings\aliases.yml"> + <ExcludeFromSingleFile>true</ExcludeFromSingleFile> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + </ItemGroup> + + <ItemGroup> + <Protobuf Include="..\EllieBot.Coordinator\Protos\coordinator.proto"> + <Link>_common\CoordinatorProtos\coordinator.proto</Link> <!-- <GrpcServices>Client</GrpcServices>--> - </Protobuf> + </Protobuf> + </ItemGroup> + + <ItemGroup> + <EditorConfigFiles Remove=".editorconfig" /> + <EditorConfigFiles Remove="Modules\Games\Fish\.editorconfig" /> </ItemGroup> <PropertyGroup Condition=" '$(Configuration)' == 'GlobalEllie' "> - <!-- Define trace doesn't seem to affect the build at all so I had to remove $(DefineConstants)--> - <DefineTrace>false</DefineTrace> - <DefineConstants>GLOBAL_ELLIE</DefineConstants> - <NoWarn>$(NoWarn);CS1573;CS1591</NoWarn> - <Optimize>true</Optimize> - <DebugType>portable</DebugType> - <DebugSymbols>false</DebugSymbols> + <!-- Define trace doesn't seem to affect the build at all so I had to remove $(DefineConstants)--> + <DefineTrace>false</DefineTrace> + <DefineConstants>GLOBAL_NADEKO</DefineConstants> + <NoWarn>$(NoWarn);CS1573;CS1591</NoWarn> + <Optimize>true</Optimize> + <DebugType>portable</DebugType> + <DebugSymbols>false</DebugSymbols> </PropertyGroup> </Project> diff --git a/src/EllieBot/Migrations/PostgreSql/20250202124835_tidy.sql b/src/EllieBot/Migrations/PostgreSql/20250202124835_tidy.sql new file mode 100644 index 0000000..de36af0 --- /dev/null +++ b/src/EllieBot/Migrations/PostgreSql/20250202124835_tidy.sql @@ -0,0 +1,14 @@ +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; + +INSERT INTO "__EFMigrationsHistory" (migrationid, productversion) +VALUES ('20250202124835_tidy', '9.0.1'); + +COMMIT; + diff --git a/src/EllieBot/Migrations/PostgreSql/20250127062816_init.Designer.cs b/src/EllieBot/Migrations/PostgreSql/20250202124905_init.Designer.cs similarity index 99% rename from src/EllieBot/Migrations/PostgreSql/20250127062816_init.Designer.cs rename to src/EllieBot/Migrations/PostgreSql/20250202124905_init.Designer.cs index afb4add..b329303 100644 --- a/src/EllieBot/Migrations/PostgreSql/20250127062816_init.Designer.cs +++ b/src/EllieBot/Migrations/PostgreSql/20250202124905_init.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace EllieBot.Migrations.PostgreSql { [DbContext(typeof(PostgreSqlContext))] - [Migration("20250127062816_init")] + [Migration("20250202124905_init")] partial class init { /// <inheritdoc /> @@ -85,10 +85,6 @@ 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"); @@ -751,10 +747,6 @@ 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"); @@ -936,10 +928,6 @@ 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"); @@ -3367,10 +3355,6 @@ 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/20250127062816_init.cs b/src/EllieBot/Migrations/PostgreSql/20250202124905_init.cs similarity index 99% rename from src/EllieBot/Migrations/PostgreSql/20250127062816_init.cs rename to src/EllieBot/Migrations/PostgreSql/20250202124905_init.cs index 0ad8347..6e4032b 100644 --- a/src/EllieBot/Migrations/PostgreSql/20250127062816_init.cs +++ b/src/EllieBot/Migrations/PostgreSql/20250202124905_init.cs @@ -36,7 +36,6 @@ 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), @@ -245,7 +244,6 @@ 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), @@ -299,7 +297,6 @@ 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), @@ -1120,7 +1117,6 @@ 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) @@ -1246,8 +1242,8 @@ namespace EllieBot.Migrations.PostgreSql { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), - guildfilterconfigid = table.Column<int>(type: "integer", nullable: true) + guildfilterconfigid = table.Column<int>(type: "integer", nullable: true), + channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false) }, constraints: table => { @@ -1265,8 +1261,8 @@ namespace EllieBot.Migrations.PostgreSql { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - word = table.Column<string>(type: "text", nullable: true), guildfilterconfigid = table.Column<int>(type: "integer", nullable: true), + word = table.Column<string>(type: "text", nullable: true), dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) }, constraints: table => @@ -1305,8 +1301,8 @@ namespace EllieBot.Migrations.PostgreSql { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), guildfilterconfigid = table.Column<int>(type: "integer", nullable: true), + channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) }, constraints: table => @@ -1483,9 +1479,9 @@ namespace EllieBot.Migrations.PostgreSql { id = table.Column<int>(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + xpsettingsid = table.Column<int>(type: "integer", nullable: true), itemid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), itemtype = table.Column<int>(type: "integer", nullable: false), - xpsettingsid = table.Column<int>(type: "integer", nullable: true), dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) }, constraints: table => diff --git a/src/EllieBot/Migrations/PostgreSql/PostgreSqlContextModelSnapshot.cs b/src/EllieBot/Migrations/PostgreSql/PostgreSqlContextModelSnapshot.cs index ad0ebcd..5d110ab 100644 --- a/src/EllieBot/Migrations/PostgreSql/PostgreSqlContextModelSnapshot.cs +++ b/src/EllieBot/Migrations/PostgreSql/PostgreSqlContextModelSnapshot.cs @@ -82,10 +82,6 @@ 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"); @@ -748,10 +744,6 @@ 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"); @@ -933,10 +925,6 @@ 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"); @@ -3364,10 +3352,6 @@ 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/20250202124832_tidy.sql b/src/EllieBot/Migrations/Sqlite/20250202124832_tidy.sql new file mode 100644 index 0000000..c1931d1 --- /dev/null +++ b/src/EllieBot/Migrations/Sqlite/20250202124832_tidy.sql @@ -0,0 +1,90 @@ +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"; + +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"; + +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"); + +COMMIT; + +INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") +VALUES ('20250202124832_tidy', '9.0.1'); + diff --git a/src/EllieBot/Migrations/Sqlite/20250127062834_init.Designer.cs b/src/EllieBot/Migrations/Sqlite/20250202124903_init.Designer.cs similarity index 99% rename from src/EllieBot/Migrations/Sqlite/20250127062834_init.Designer.cs rename to src/EllieBot/Migrations/Sqlite/20250202124903_init.Designer.cs index 6e40885..ffb15cb 100644 --- a/src/EllieBot/Migrations/Sqlite/20250127062834_init.Designer.cs +++ b/src/EllieBot/Migrations/Sqlite/20250202124903_init.Designer.cs @@ -11,7 +11,7 @@ using EllieBot.Db; namespace EllieBot.Migrations.Sqlite { [DbContext(typeof(SqliteContext))] - [Migration("20250127062834_init")] + [Migration("20250202124903_init")] partial class init { /// <inheritdoc /> @@ -64,9 +64,6 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int>("GuildConfigId") - .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); @@ -562,9 +559,6 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int>("GuildConfigId") - .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); @@ -700,9 +694,6 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int>("GuildConfigId") - .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); @@ -2505,9 +2496,6 @@ 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/20250127062834_init.cs b/src/EllieBot/Migrations/Sqlite/20250202124903_init.cs similarity index 99% rename from src/EllieBot/Migrations/Sqlite/20250127062834_init.cs rename to src/EllieBot/Migrations/Sqlite/20250202124903_init.cs index b91fdd7..1f7ecdc 100644 --- a/src/EllieBot/Migrations/Sqlite/20250127062834_init.cs +++ b/src/EllieBot/Migrations/Sqlite/20250202124903_init.cs @@ -35,7 +35,6 @@ 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), @@ -244,7 +243,6 @@ 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), @@ -298,7 +296,6 @@ 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), @@ -1122,7 +1119,6 @@ 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) @@ -1248,8 +1244,8 @@ namespace EllieBot.Migrations.Sqlite { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), - GuildFilterConfigId = table.Column<int>(type: "INTEGER", nullable: true) + GuildFilterConfigId = table.Column<int>(type: "INTEGER", nullable: true), + ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false) }, constraints: table => { @@ -1267,8 +1263,8 @@ namespace EllieBot.Migrations.Sqlite { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - Word = table.Column<string>(type: "TEXT", nullable: true), GuildFilterConfigId = table.Column<int>(type: "INTEGER", nullable: true), + Word = table.Column<string>(type: "TEXT", nullable: true), DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) }, constraints: table => @@ -1307,8 +1303,8 @@ namespace EllieBot.Migrations.Sqlite { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), GuildFilterConfigId = table.Column<int>(type: "INTEGER", nullable: true), + ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) }, constraints: table => @@ -1485,9 +1481,9 @@ namespace EllieBot.Migrations.Sqlite { Id = table.Column<int>(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), + XpSettingsId = table.Column<int>(type: "INTEGER", nullable: true), ItemId = table.Column<ulong>(type: "INTEGER", nullable: false), ItemType = table.Column<int>(type: "INTEGER", nullable: false), - XpSettingsId = table.Column<int>(type: "INTEGER", nullable: true), DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) }, constraints: table => diff --git a/src/EllieBot/Migrations/Sqlite/SqliteContextModelSnapshot.cs b/src/EllieBot/Migrations/Sqlite/SqliteContextModelSnapshot.cs index 457aec3..084a0ee 100644 --- a/src/EllieBot/Migrations/Sqlite/SqliteContextModelSnapshot.cs +++ b/src/EllieBot/Migrations/Sqlite/SqliteContextModelSnapshot.cs @@ -61,9 +61,6 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int>("GuildConfigId") - .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); @@ -559,9 +556,6 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int>("GuildConfigId") - .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); @@ -697,9 +691,6 @@ namespace EllieBot.Migrations.Sqlite b.Property<DateTime?>("DateAdded") .HasColumnType("TEXT"); - b.Property<int>("GuildConfigId") - .HasColumnType("INTEGER"); - b.Property<ulong>("GuildId") .HasColumnType("INTEGER"); @@ -2502,9 +2493,6 @@ 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/Games/ChatterBot/_common/OpenAiApiSession.cs b/src/EllieBot/Modules/Games/ChatterBot/_common/OpenAiApiSession.cs index 42afd22..64aacbc 100644 --- a/src/EllieBot/Modules/Games/ChatterBot/_common/OpenAiApiSession.cs +++ b/src/EllieBot/Modules/Games/ChatterBot/_common/OpenAiApiSession.cs @@ -111,8 +111,20 @@ public partial class OpenAiApiSession : IChatterBotSession }); var dataString = await data.Content.ReadAsStringAsync(); + try { + data.EnsureSuccessStatusCode(); + } + catch (Exception ex) + { + Log.Error(ex, "Failed to get response from OpenAI: {Message}", ex.Message); + return new Error<string>("Failed to get response from OpenAI"); + } + + try + { + var response = JsonConvert.DeserializeObject<OpenAiCompletionResponse>(dataString); // Log.Information("Received response: {Response} ", dataString); diff --git a/src/EllieBot/Modules/Xp/XpService.cs b/src/EllieBot/Modules/Xp/XpService.cs index 4d14ce8..7ba2705 100644 --- a/src/EllieBot/Modules/Xp/XpService.cs +++ b/src/EllieBot/Modules/Xp/XpService.cs @@ -128,15 +128,9 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand foreach (var item in xp.ExclusionList) { if (item.ItemType == ExcludedItemType.Channel) - { - if (_excludedChannels.TryGetValue(xp.GuildId, out var channels)) - channels.Add(item.ItemId); - } + _excludedChannels.GetOrAdd(xp.GuildId, static _ => []).Add(item.ItemId); else if (item.ItemType == ExcludedItemType.Role) - { - if (_excludedRoles.TryGetValue(xp.GuildId, out var roles)) - roles.Add(item.ItemId); - } + _excludedRoles.GetOrAdd(xp.GuildId, static _ => []).Add(item.ItemId); } } } diff --git a/src/EllieBot/data/games.yml b/src/EllieBot/data/games.yml index 01f0261..0118e2c 100644 --- a/src/EllieBot/data/games.yml +++ b/src/EllieBot/data/games.yml @@ -62,13 +62,13 @@ chatGpt: # Url to any openai api compatible url. # Make sure to modify the modelName appropriately # DO NOT add /v1/chat/completions suffix to the url - apiUrl: https://api.openai.com + apiUrl: https://api.groq.com/openai # Which GPT Model should bot use. # gpt-3.5-turbo - cheapest # gpt-4o - more expensive, higher quality # # If you are using another openai compatible api, you may use any of the models supported by that api - modelName: gpt-3.5-turbo + modelName: llama-3.3-70b-versatile # How should the chatbot behave, what's its personality? # This will be sent as a system message. # Usage of this counts towards the max tokens.