← All source files

V14 / fad4e1a110e5

MessageCommands.cs

Lilith/Core/Messaging/MessageCommands.cs

Changed in this version
CS
using Lilith.Core.Commands;

namespace Lilith.Core.Messaging;

public static class MessageCommands
{
    public static void Register(ChatCommandRegistry commands, Func<ProviderClient> provider)
    {
        foreach (bool approve in new[] { true, false })
        {
            bool decision = approve;
            commands.RegisterAsync(approve ? "message-approve" : "message-reject", "Apply the exact prepared message: NICKNAME PROPOSAL_ID. Dummy channels simulate delivery only.", async c =>
            {
                string[] parts = c.Arguments.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length != 2) throw new ArgumentException("Specify nickname and proposal ID.");
                return new(true, await provider().DecideMessageAsync(parts[0], parts[1], decision, c.CancellationToken));
            });
        }
    }
}