about summary refs log tree commit diff
path: root/Utilities/LibMatrix.DevTestBot/Bot/Interfaces/CommandContext.cs
blob: 221d1f491a120d44df9bb6ebf67b7e8eaac76314 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
using LibMatrix.EventTypes.Spec;
using LibMatrix.RoomTypes;

namespace LibMatrix.ExampleBot.Bot.Interfaces;

public class CommandContext {
    public required GenericRoom Room { get; init; }
    public required StateEventResponse MessageEvent { get; init; }
    public string CommandName => MessageContent.Body.Split(' ')[0][1..];
    public string[] Args => MessageContent.Body.Split(' ')[1..];
    private RoomMessageEventContent MessageContent => MessageEvent.TypedContent as RoomMessageEventContent ?? throw new Exception("Message content is not a RoomMessageEventContent");
}