Added a generic interface for retrieving images. Where multiple images exist, it'll retrieve the least seen. If there are sufficient images to work with, it'll randomly pick from a subset of the least seen to make it less predictable what's going to show up.

This commit is contained in:
barelyprofessional
2025-02-15 23:31:26 +08:00
parent 5eb2ef62b9
commit 7e9137c35c
10 changed files with 642 additions and 297 deletions

View File

@@ -0,0 +1,48 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace KfChatDotNetBot.Migrations
{
/// <inheritdoc />
public partial class Images : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "ValueType",
table: "Settings",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "Images",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Key = table.Column<string>(type: "TEXT", nullable: false),
Url = table.Column<string>(type: "TEXT", nullable: false),
LastSeen = table.Column<DateTimeOffset>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Images", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Images");
migrationBuilder.DropColumn(
name: "ValueType",
table: "Settings");
}
}
}