blob: 1b69c8942747ccfcfc5814724f4e6b41d7f4a319 (
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
32
33
34
35
36
|
using LibMatrix.Homeservers;
using LibMatrix.LegacyEvents.EventTypes.Spec;
using LibMatrix.RoomTypes;
namespace LibMatrix.Utilities.Bot.Interfaces;
public class CommandContext {
public required GenericRoom Room { get; set; }
public required LegacyMatrixEventResponse MessageEvent { get; set; }
public string MessageContentWithoutReply =>
(MessageEvent.TypedContent as RoomMessageLegacyEventContent)!
.Body.Split('\n')
.SkipWhile(x => x.StartsWith(">"))
.Aggregate((x, y) => $"{x}\n{y}");
public required string CommandName;
public required string[] Args;
public required AuthenticatedHomeserverGeneric Homeserver { get; set; }
public async Task<EventIdResponse> Reply(RoomMessageLegacyEventContent content) => await Room.SendMessageEventAsync(content);
}
public class CommandResult {
public required bool Success { get; set; }
public Exception? Exception { get; set; }
public required CommandResultType Result { get; set; }
public required CommandContext Context { get; set; }
public enum CommandResultType {
Success,
Failure_Exception,
Failure_NoPermission,
Failure_InvalidCommand
}
}
|