added another migration to clean up some remainig FKs, show error in openai if the request is not successful

This commit is contained in:
Toastie 2025-02-04 01:16:35 +13:00
parent f5a0c81e64
commit 4192d493df
Signed by: toastie_t0ast
GPG key ID: 0861BE54AD481DC7
13 changed files with 261 additions and 211 deletions

View file

@ -7,5 +7,5 @@ public class FilteredWord : DbEntity
public override bool Equals(object? obj) => obj is FilteredWord fw && fw.Word == Word; 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;
} }

View file

@ -1,159 +1,163 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings> <ImplicitUsings>true</ImplicitUsings>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<Version>5.3.9</Version> <Version>5.3.9</Version>
<!-- Output/build --> <!-- Output/build -->
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> <RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
<OutputType>exe</OutputType> <OutputType>exe</OutputType>
<ApplicationIcon>ellie_icon.ico</ApplicationIcon> <ApplicationIcon>ellie_icon.ico</ApplicationIcon>
<!-- Analysis/Warnings --> <!-- Analysis/Warnings -->
<!-- <AnalysisMode>Recommended</AnalysisMode>--> <!-- <AnalysisMode>Recommended</AnalysisMode>-->
<!-- <AnalysisModeGlobalization>None</AnalysisModeGlobalization>--> <!-- <AnalysisModeGlobalization>None</AnalysisModeGlobalization>-->
<NoWarn>CS1066;CS8981</NoWarn> <NoWarn>CS1066;CS8981</NoWarn>
<!-- Profile-guided optimization --> <!-- Profile-guided optimization -->
<TieredPGO>true</TieredPGO> <TieredPGO>true</TieredPGO>
<DebugType>embedded</DebugType> <DebugType>embedded</DebugType>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AngleSharp" Version="1.2.0"> <PackageReference Include="AngleSharp" Version="1.2.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<Publish>True</Publish> <Publish>True</Publish>
</PackageReference> </PackageReference>
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.6" /> <PackageReference Include="CodeHollow.FeedReader" Version="1.2.6"/>
<PackageReference Include="CommandLineParser" Version="2.9.1" /> <PackageReference Include="CommandLineParser" Version="2.9.1"/>
<PackageReference Include="Discord.Net" Version="3.17.1" /> <PackageReference Include="Discord.Net" Version="3.17.1" />
<PackageReference Include="CoreCLR-NCalc" Version="3.1.253" /> <PackageReference Include="CoreCLR-NCalc" Version="3.1.253" />
<PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138" /> <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.YouTube.v3" Version="1.68.0.3653" />
<PackageReference Include="Google.Apis.Customsearch.v1" Version="1.49.0.2084" /> <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="Microsoft.Extensions.Configuration" Version="9.0.1" />
<PackageReference Include="Grpc" Version="2.46.6" /> <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.1" />
<PackageReference Include="Grpc.Net.Client" Version="2.67.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.1" />
<PackageReference Include="Grpc.Tools" Version="2.69.0" PrivateAssets="All" />
<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" /> <!-- DI -->
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.1" /> <!-- <PackageReference Include="Ninject" Version="3.3.6"/>-->
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.1" /> <!-- <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="Microsoft.Extensions.Http" Version="9.0.1" />
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" /> <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="SixLabors.Fonts" Version="2.1.0" />
<!-- <PackageReference Include="Ninject" Version="3.3.6"/>--> <PackageReference Include="SixLabors.ImageSharp" Version="3.1.6" />
<!-- <PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0"/>--> <PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.5" />
<!-- <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />--> <PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0009"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.1" /> <PackageReference Include="StackExchange.Redis" Version="2.8.24" />
<PackageReference Include="DryIoc.dll" Version="5.4.3" /> <PackageReference Include="YamlDotNet" Version="15.1.6" />
<!-- <PackageReference Include="Scrutor" Version="4.2.0" />--> <PackageReference Include="SharpToken" Version="2.0.3"/>
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.1" /> <PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
<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" />
<!-- Db-related packages --> <!-- Db-related packages -->
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.1"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.1">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </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="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" /> <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 --> <!-- Used by stream notifications -->
<PackageReference Include="TwitchLib.Api" Version="3.9.0" /> <PackageReference Include="TwitchLib.Api" Version="3.9.0" />
<!-- sqlselectcsv and stock --> <!-- sqlselectcsv and stock -->
<PackageReference Include="CsvHelper" Version="33.0.1" /> <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>
<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>
<ItemGroup> <ItemGroup>
<None Update="data\**\*"> <AdditionalFiles Include="strings\responses\responses.en-US.json"/>
<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>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Protobuf Include="..\EllieBot.Coordinator\Protos\coordinator.proto"> <None Update="data\**\*">
<Link>_common\CoordinatorProtos\coordinator.proto</Link> <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>--> <!-- <GrpcServices>Client</GrpcServices>-->
</Protobuf> </Protobuf>
</ItemGroup>
<ItemGroup>
<EditorConfigFiles Remove=".editorconfig" />
<EditorConfigFiles Remove="Modules\Games\Fish\.editorconfig" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'GlobalEllie' "> <PropertyGroup Condition=" '$(Configuration)' == 'GlobalEllie' ">
<!-- Define trace doesn't seem to affect the build at all so I had to remove $(DefineConstants)--> <!-- Define trace doesn't seem to affect the build at all so I had to remove $(DefineConstants)-->
<DefineTrace>false</DefineTrace> <DefineTrace>false</DefineTrace>
<DefineConstants>GLOBAL_ELLIE</DefineConstants> <DefineConstants>GLOBAL_NADEKO</DefineConstants>
<NoWarn>$(NoWarn);CS1573;CS1591</NoWarn> <NoWarn>$(NoWarn);CS1573;CS1591</NoWarn>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>portable</DebugType> <DebugType>portable</DebugType>
<DebugSymbols>false</DebugSymbols> <DebugSymbols>false</DebugSymbols>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View file

@ -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;

View file

@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace EllieBot.Migrations.PostgreSql namespace EllieBot.Migrations.PostgreSql
{ {
[DbContext(typeof(PostgreSqlContext))] [DbContext(typeof(PostgreSqlContext))]
[Migration("20250127062816_init")] [Migration("20250202124905_init")]
partial class init partial class init
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -85,10 +85,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone") .HasColumnType("timestamp without time zone")
.HasColumnName("dateadded"); .HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId") b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)") .HasColumnType("numeric(20,0)")
.HasColumnName("guildid"); .HasColumnName("guildid");
@ -751,10 +747,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone") .HasColumnType("timestamp without time zone")
.HasColumnName("dateadded"); .HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId") b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)") .HasColumnType("numeric(20,0)")
.HasColumnName("guildid"); .HasColumnName("guildid");
@ -936,10 +928,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone") .HasColumnType("timestamp without time zone")
.HasColumnName("dateadded"); .HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId") b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)") .HasColumnType("numeric(20,0)")
.HasColumnName("guildid"); .HasColumnName("guildid");
@ -3367,10 +3355,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone") .HasColumnType("timestamp without time zone")
.HasColumnName("dateadded"); .HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId") b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)") .HasColumnType("numeric(20,0)")
.HasColumnName("guildid"); .HasColumnName("guildid");

View file

@ -36,7 +36,6 @@ namespace EllieBot.Migrations.PostgreSql
{ {
id = table.Column<int>(type: "integer", nullable: false) id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
guildconfigid = table.Column<int>(type: "integer", nullable: false),
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
userthreshold = table.Column<int>(type: "integer", nullable: false), userthreshold = table.Column<int>(type: "integer", nullable: false),
seconds = 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) id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
guildconfigid = table.Column<int>(type: "integer", nullable: false),
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
channelid = 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), state = table.Column<bool>(type: "boolean", nullable: false),
@ -299,7 +297,6 @@ namespace EllieBot.Migrations.PostgreSql
{ {
id = table.Column<int>(type: "integer", nullable: false) id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
guildconfigid = table.Column<int>(type: "integer", nullable: false),
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
channelid = 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), url = table.Column<string>(type: "text", nullable: true),
@ -1120,7 +1117,6 @@ namespace EllieBot.Migrations.PostgreSql
{ {
id = table.Column<int>(type: "integer", nullable: false) id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
guildconfigid = table.Column<int>(type: "integer", nullable: false),
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
serverexcluded = table.Column<bool>(type: "boolean", nullable: false), serverexcluded = table.Column<bool>(type: "boolean", nullable: false),
dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) 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) id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .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 => constraints: table =>
{ {
@ -1265,8 +1261,8 @@ namespace EllieBot.Migrations.PostgreSql
{ {
id = table.Column<int>(type: "integer", nullable: false) id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
word = table.Column<string>(type: "text", nullable: true),
guildfilterconfigid = table.Column<int>(type: "integer", 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) dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
}, },
constraints: table => constraints: table =>
@ -1305,8 +1301,8 @@ namespace EllieBot.Migrations.PostgreSql
{ {
id = table.Column<int>(type: "integer", nullable: false) id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .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),
dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true) dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
}, },
constraints: table => constraints: table =>
@ -1483,9 +1479,9 @@ namespace EllieBot.Migrations.PostgreSql
{ {
id = table.Column<int>(type: "integer", nullable: false) id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
xpsettingsid = table.Column<int>(type: "integer", nullable: true),
itemid = table.Column<decimal>(type: "numeric(20,0)", nullable: false), itemid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
itemtype = table.Column<int>(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: "timestamp without time zone", nullable: true) dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
}, },
constraints: table => constraints: table =>

View file

@ -82,10 +82,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone") .HasColumnType("timestamp without time zone")
.HasColumnName("dateadded"); .HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId") b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)") .HasColumnType("numeric(20,0)")
.HasColumnName("guildid"); .HasColumnName("guildid");
@ -748,10 +744,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone") .HasColumnType("timestamp without time zone")
.HasColumnName("dateadded"); .HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId") b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)") .HasColumnType("numeric(20,0)")
.HasColumnName("guildid"); .HasColumnName("guildid");
@ -933,10 +925,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone") .HasColumnType("timestamp without time zone")
.HasColumnName("dateadded"); .HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId") b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)") .HasColumnType("numeric(20,0)")
.HasColumnName("guildid"); .HasColumnName("guildid");
@ -3364,10 +3352,6 @@ namespace EllieBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone") .HasColumnType("timestamp without time zone")
.HasColumnName("dateadded"); .HasColumnName("dateadded");
b.Property<int>("GuildConfigId")
.HasColumnType("integer")
.HasColumnName("guildconfigid");
b.Property<decimal>("GuildId") b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)") .HasColumnType("numeric(20,0)")
.HasColumnName("guildid"); .HasColumnName("guildid");

View file

@ -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');

View file

@ -11,7 +11,7 @@ using EllieBot.Db;
namespace EllieBot.Migrations.Sqlite namespace EllieBot.Migrations.Sqlite
{ {
[DbContext(typeof(SqliteContext))] [DbContext(typeof(SqliteContext))]
[Migration("20250127062834_init")] [Migration("20250202124903_init")]
partial class init partial class init
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -64,9 +64,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded") b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId") b.Property<ulong>("GuildId")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
@ -562,9 +559,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded") b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId") b.Property<ulong>("GuildId")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
@ -700,9 +694,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded") b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId") b.Property<ulong>("GuildId")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
@ -2505,9 +2496,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded") b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId") b.Property<ulong>("GuildId")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");

View file

@ -35,7 +35,6 @@ namespace EllieBot.Migrations.Sqlite
{ {
Id = table.Column<int>(type: "INTEGER", nullable: false) Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Sqlite:Autoincrement", true),
GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false),
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
UserThreshold = table.Column<int>(type: "INTEGER", nullable: false), UserThreshold = table.Column<int>(type: "INTEGER", nullable: false),
Seconds = 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) Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Sqlite:Autoincrement", true),
GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false),
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false),
State = table.Column<bool>(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) Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Sqlite:Autoincrement", true),
GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false),
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false), ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false),
Url = table.Column<string>(type: "TEXT", nullable: true), Url = table.Column<string>(type: "TEXT", nullable: true),
@ -1122,7 +1119,6 @@ namespace EllieBot.Migrations.Sqlite
{ {
Id = table.Column<int>(type: "INTEGER", nullable: false) Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Sqlite:Autoincrement", true),
GuildConfigId = table.Column<int>(type: "INTEGER", nullable: false),
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false), GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
ServerExcluded = table.Column<bool>(type: "INTEGER", nullable: false), ServerExcluded = table.Column<bool>(type: "INTEGER", nullable: false),
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true)
@ -1248,8 +1244,8 @@ namespace EllieBot.Migrations.Sqlite
{ {
Id = table.Column<int>(type: "INTEGER", nullable: false) Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .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 => constraints: table =>
{ {
@ -1267,8 +1263,8 @@ namespace EllieBot.Migrations.Sqlite
{ {
Id = table.Column<int>(type: "INTEGER", nullable: false) Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Sqlite:Autoincrement", true),
Word = table.Column<string>(type: "TEXT", nullable: true),
GuildFilterConfigId = table.Column<int>(type: "INTEGER", 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) DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true)
}, },
constraints: table => constraints: table =>
@ -1307,8 +1303,8 @@ namespace EllieBot.Migrations.Sqlite
{ {
Id = table.Column<int>(type: "INTEGER", nullable: false) Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .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),
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true) DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true)
}, },
constraints: table => constraints: table =>
@ -1485,9 +1481,9 @@ namespace EllieBot.Migrations.Sqlite
{ {
Id = table.Column<int>(type: "INTEGER", nullable: false) Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Sqlite:Autoincrement", true),
XpSettingsId = table.Column<int>(type: "INTEGER", nullable: true),
ItemId = table.Column<ulong>(type: "INTEGER", nullable: false), ItemId = table.Column<ulong>(type: "INTEGER", nullable: false),
ItemType = table.Column<int>(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) DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true)
}, },
constraints: table => constraints: table =>

View file

@ -61,9 +61,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded") b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId") b.Property<ulong>("GuildId")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
@ -559,9 +556,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded") b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId") b.Property<ulong>("GuildId")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
@ -697,9 +691,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded") b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId") b.Property<ulong>("GuildId")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
@ -2502,9 +2493,6 @@ namespace EllieBot.Migrations.Sqlite
b.Property<DateTime?>("DateAdded") b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("GuildConfigId")
.HasColumnType("INTEGER");
b.Property<ulong>("GuildId") b.Property<ulong>("GuildId")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");

View file

@ -111,8 +111,20 @@ public partial class OpenAiApiSession : IChatterBotSession
}); });
var dataString = await data.Content.ReadAsStringAsync(); var dataString = await data.Content.ReadAsStringAsync();
try 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); var response = JsonConvert.DeserializeObject<OpenAiCompletionResponse>(dataString);
// Log.Information("Received response: {Response} ", dataString); // Log.Information("Received response: {Response} ", dataString);

View file

@ -128,15 +128,9 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
foreach (var item in xp.ExclusionList) foreach (var item in xp.ExclusionList)
{ {
if (item.ItemType == ExcludedItemType.Channel) if (item.ItemType == ExcludedItemType.Channel)
{ _excludedChannels.GetOrAdd(xp.GuildId, static _ => []).Add(item.ItemId);
if (_excludedChannels.TryGetValue(xp.GuildId, out var channels))
channels.Add(item.ItemId);
}
else if (item.ItemType == ExcludedItemType.Role) else if (item.ItemType == ExcludedItemType.Role)
{ _excludedRoles.GetOrAdd(xp.GuildId, static _ => []).Add(item.ItemId);
if (_excludedRoles.TryGetValue(xp.GuildId, out var roles))
roles.Add(item.ItemId);
}
} }
} }
} }

View file

@ -62,13 +62,13 @@ chatGpt:
# Url to any openai api compatible url. # Url to any openai api compatible url.
# Make sure to modify the modelName appropriately # Make sure to modify the modelName appropriately
# DO NOT add /v1/chat/completions suffix to the url # 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. # Which GPT Model should bot use.
# gpt-3.5-turbo - cheapest # gpt-3.5-turbo - cheapest
# gpt-4o - more expensive, higher quality # 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 # 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? # How should the chatbot behave, what's its personality?
# This will be sent as a system message. # This will be sent as a system message.
# Usage of this counts towards the max tokens. # Usage of this counts towards the max tokens.