2021-08-27 11:03:47 -04:00
|
|
|
using System.Threading.Tasks;
|
2020-10-23 12:18:28 +02:00
|
|
|
|
|
|
|
|
using NodaTime;
|
|
|
|
|
|
|
|
|
|
using PluralKit.Core;
|
|
|
|
|
|
|
|
|
|
using Serilog;
|
|
|
|
|
|
|
|
|
|
namespace PluralKit.Bot
|
|
|
|
|
{
|
|
|
|
|
public class CommandMessageService
|
|
|
|
|
{
|
|
|
|
|
private readonly IDatabase _db;
|
|
|
|
|
private readonly ModelRepository _repo;
|
|
|
|
|
private readonly IClock _clock;
|
|
|
|
|
private readonly ILogger _logger;
|
2021-08-27 11:03:47 -04:00
|
|
|
|
2020-10-23 12:18:28 +02:00
|
|
|
public CommandMessageService(IDatabase db, ModelRepository repo, IClock clock, ILogger logger)
|
|
|
|
|
{
|
|
|
|
|
_db = db;
|
|
|
|
|
_repo = repo;
|
|
|
|
|
_clock = clock;
|
2021-06-10 14:21:05 +02:00
|
|
|
_logger = logger.ForContext<CommandMessageService>();
|
2020-10-23 12:18:28 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-26 22:49:43 -04:00
|
|
|
public async Task RegisterMessage(ulong messageId, ulong channelId, ulong authorId)
|
2020-10-23 12:18:28 +02:00
|
|
|
{
|
2021-09-26 22:49:43 -04:00
|
|
|
_logger.Debug("Registering command response {MessageId} from author {AuthorId} in {ChannelId}", messageId, authorId, channelId);
|
2021-09-29 21:51:38 -04:00
|
|
|
await _repo.SaveCommandMessage(messageId, channelId, authorId);
|
2020-10-23 12:18:28 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-29 21:51:38 -04:00
|
|
|
public async Task<CommandMessage?> GetCommandMessage(ulong messageId)
|
2020-10-23 12:18:28 +02:00
|
|
|
{
|
2021-09-29 21:51:38 -04:00
|
|
|
return await _repo.GetCommandMessage(messageId);
|
2020-10-23 12:18:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|