about summary refs log tree commit diff
path: root/MiniUtils/Commands/MscCommand.cs
blob: 89e9aecb4d1564a766a769c09512c6fef2043ba0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using LibMatrix.Helpers;
using LibMatrix.Utilities.Bot.Interfaces;
using MiniUtils.Utilities;

namespace MiniUtils.Commands;

public class MscCommand(MscInfoProvider mscInfoProvider) : ICommand {
    public string Name { get; } = "msc";
    public string[]? Aliases { get; } = [];
    public string Description { get; } = "Get MSC info";
    public bool Unlisted { get; } = false;

    public async Task Invoke(CommandContext ctx) {
        var msb = new MessageBuilder("m.notice");
        var id = int.Parse(ctx.Args[0]);
        var mscInfo = await mscInfoProvider.GetMscInfo(id);

        msb.WithBody(mscInfo?.ToHtml() ?? "No info found!");

        await ctx.Reply(msb.Build());
        Console.WriteLine(msb.Build().FormattedBody);
    }
}