about summary refs log tree commit diff
path: root/MiniUtils/Commands
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-05-15 08:14:26 +0200
committerRory& <root@rory.gay>2025-05-15 09:28:03 +0200
commitaa6ac5e7162558409417d8eb7e3152ad3d3b3134 (patch)
tree784ac6771cec31e15998cd6513d466e1dcde6cf8 /MiniUtils/Commands
parentInitial commit (diff)
downloadMiniUtils-aa6ac5e7162558409417d8eb7e3152ad3d3b3134.tar.xz
Add more commands
Diffstat (limited to 'MiniUtils/Commands')
-rw-r--r--MiniUtils/Commands/DeleteRoomCommand.cs47
-rw-r--r--MiniUtils/Commands/MakePolicyListCommand.cs47
2 files changed, 94 insertions, 0 deletions
diff --git a/MiniUtils/Commands/DeleteRoomCommand.cs b/MiniUtils/Commands/DeleteRoomCommand.cs
new file mode 100644

index 0000000..41dbfb3 --- /dev/null +++ b/MiniUtils/Commands/DeleteRoomCommand.cs
@@ -0,0 +1,47 @@ +using ArcaneLibs.Extensions; +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 DeleteRoomCommand() : ICommand { + public string Name => "delete room"; + + public string[]? Aliases => ["deleteroom"]; + + public string Description => "Delete a room"; + + 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()); + } +} \ No newline at end of file diff --git a/MiniUtils/Commands/MakePolicyListCommand.cs b/MiniUtils/Commands/MakePolicyListCommand.cs new file mode 100644
index 0000000..0498712 --- /dev/null +++ b/MiniUtils/Commands/MakePolicyListCommand.cs
@@ -0,0 +1,47 @@ +using ArcaneLibs.Extensions; +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()); + } +} \ No newline at end of file