2020-10-18 05:18:52 +00:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
using Dapper;
|
|
|
|
|
|
|
|
namespace PluralKit.Core
|
|
|
|
{
|
|
|
|
public partial class ModelRepository
|
2021-08-27 15:03:47 +00:00
|
|
|
{
|
|
|
|
public Task SaveCommandMessage(IPKConnection conn, ulong messageId, ulong authorId) =>
|
|
|
|
conn.QueryAsync("insert into command_messages (message_id, author_id) values (@Message, @Author)",
|
|
|
|
new { Message = messageId, Author = authorId });
|
2020-10-18 05:59:36 +00:00
|
|
|
|
2021-08-27 15:03:47 +00:00
|
|
|
public Task<CommandMessage> GetCommandMessage(IPKConnection conn, ulong messageId) =>
|
|
|
|
conn.QuerySingleOrDefaultAsync<CommandMessage>("select * from command_messages where message_id = @Message",
|
|
|
|
new { Message = messageId });
|
2020-10-23 10:18:28 +00:00
|
|
|
|
|
|
|
public Task<int> DeleteCommandMessagesBefore(IPKConnection conn, ulong messageIdThreshold) =>
|
|
|
|
conn.ExecuteAsync("delete from command_messages where message_id < @Threshold",
|
2021-08-27 15:03:47 +00:00
|
|
|
new { Threshold = messageIdThreshold });
|
2020-10-23 10:18:28 +00:00
|
|
|
}
|
2020-10-18 05:59:36 +00:00
|
|
|
|
2021-08-27 15:03:47 +00:00
|
|
|
public class CommandMessage
|
|
|
|
{
|
2020-10-23 10:18:28 +00:00
|
|
|
public ulong AuthorId { get; set; }
|
|
|
|
public ulong MessageId { get; set; }
|
2021-08-27 15:03:47 +00:00
|
|
|
}
|
2020-10-18 05:18:52 +00:00
|
|
|
}
|