- Add storing bot response messages in postgres
- Add scheduled task to clean up said store
This commit is contained in:
@@ -19,7 +19,7 @@ namespace PluralKit.Core
|
||||
internal class Database: IDatabase
|
||||
{
|
||||
private const string RootPath = "PluralKit.Core.Database"; // "resource path" root for SQL files
|
||||
private const int TargetSchemaVersion = 10;
|
||||
private const int TargetSchemaVersion = 11;
|
||||
|
||||
private readonly CoreConfig _config;
|
||||
private readonly ILogger _logger;
|
||||
|
17
PluralKit.Core/Database/Migrations/11.sql
Normal file
17
PluralKit.Core/Database/Migrations/11.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- SCHEMA VERSION 11: (insert date) --
|
||||
-- Create command message table --
|
||||
|
||||
create table command_message
|
||||
(
|
||||
message_id bigint primary key,
|
||||
invoker_id bigint not null,
|
||||
timestamp timestamp not null default now()
|
||||
);
|
||||
|
||||
create function cleanup_command_message() returns void as $$
|
||||
begin
|
||||
delete from command_message where timestamp < now() - interval '1 minute';
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
update info set schema_version = 11;
|
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dapper;
|
||||
|
||||
namespace PluralKit.Core
|
||||
{
|
||||
public partial class ModelRepository
|
||||
{
|
||||
public Task SaveCommandMessage(IPKConnection conn, ulong message_id, ulong author_id) =>
|
||||
conn.QueryAsync("insert into command_message (message_id, invoker_id) values (@Message, @Author)",
|
||||
new {Message = message_id, Author = author_id });
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user