blob: 40b0695ee7c8ebbfe255015f8b9caf160e10555f (
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
37
38
39
40
41
42
43
44
45
46
|
using LibMatrix.EventTypes.Common;
using LibMatrix.EventTypes.Spec.State.RoomInfo;
using LibMatrix.Helpers;
using LibMatrix.Responses;
using LibMatrix.RoomTypes;
using LibMatrix.Utilities.Bot.Interfaces;
namespace MiniUtils.Commands;
public class MakePolicyListCommand() : ICommand {
public string Name => "makepolicylist";
public string[]? Aliases => ["make policy list"];
public string Description => "Make a new policy list";
public bool Unlisted => false;
public async Task Invoke(CommandContext ctx) {
var creationContent = new CreateRoomRequest() {
Name = ctx.Args[0],
RoomAliasName = ctx.Args[0],
Visibility = "private",
CreationContent = new() {
{ "type", PolicyRoom.TypeName },
{ "room_version", 11 }
},
PowerLevelContentOverride = new RoomPowerLevelEventContent() {
EventsDefault = 50,
Invite = 50
},
InitialState = [
new() {
Type = MjolnirShortcodeEventContent.EventId,
StateKey = "",
TypedContent = new MjolnirShortcodeEventContent() {
Shortcode = ctx.Args[0]
}
}
]
};
var result = await ctx.Homeserver.CreateRoom(creationContent);
await ctx.Room.SendMessageEventAsync(new MessageBuilder().WithMention($"#{ctx.Args[0]}:{ctx.Homeserver.ServerName}").Build());
}
}
|