about summary refs log tree commit diff
path: root/MatrixContentFilter/Commands/DumpEventCommand.cs
blob: 5131e191c2f600c183d9eb2eae24285885363718 (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
24
25
26
27
28
29
30
31
using ArcaneLibs.Extensions;
using LibMatrix.EventTypes.Spec;
using LibMatrix.EventTypes.Spec.State;
using LibMatrix.Filters;
using LibMatrix.Helpers;
using LibMatrix.Homeservers;
using LibMatrix.Utilities.Bot.Interfaces;
using MatrixContentFilter.Abstractions;
using MatrixContentFilter.Services;
using MatrixContentFilter.Services.AsyncActionQueues;
using Microsoft.Extensions.Logging;

namespace MatrixContentFilter.Commands;

public class DumpEventCommand(
    ConfigurationService filterConfigService,
    AsyncMessageQueue msgQueue,
    InfoCacheService infoCache,
    ConfigurationService cfgService,
    AbstractAsyncActionQueue actionQueue
) : ICommand {
    public string Name { get; } = "dump";
    public string[]? Aliases { get; } = [];
    public string Description { get; } = "Dump event by ID";
    public bool Unlisted { get; } = false;

    public async Task Invoke(CommandContext ctx) {
        var evt = await ctx.Room.GetEventAsync(ctx.Args[0]);
        await ctx.Room.SendMessageEventAsync(new MessageBuilder("m.notice").WithBody(evt.ToJson(ignoreNull: true)).Build());
    }
}