about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
m---------LibMatrix0
-rw-r--r--MiniUtils.sln.DotSettings.user1
-rw-r--r--MiniUtils/Commands/DeleteRoomCommand.cs47
-rw-r--r--MiniUtils/Commands/MakePolicyListCommand.cs47
4 files changed, 95 insertions, 0 deletions
diff --git a/LibMatrix b/LibMatrix
-Subproject c83054203dda13035028e4ea824d74e213ec997
+Subproject dae1a25664606415e054f3e3b20bbbfabdbb0e9
diff --git a/MiniUtils.sln.DotSettings.user b/MiniUtils.sln.DotSettings.user

index 76198cf..2946aec 100644 --- a/MiniUtils.sln.DotSettings.user +++ b/MiniUtils.sln.DotSettings.user
@@ -7,6 +7,7 @@ <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AList_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fea51ca5e833244688d7ca912cfc70784d19c00_003F65_003Fb77a719c_003FList_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AList_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ff1b929573c264d7a81f261ae2f951019d19e00_003F2f_003F707c45aa_003FList_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AObjectExtensions_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F8fd5e96d6574456095123be1ecfbdfa914200_003Fe2_003F3561a383_003FObjectExtensions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> + <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARune_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ff1b929573c264d7a81f261ae2f951019d19e00_003F50_003F2cf1d657_003FRune_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AServiceCollectionHostedServiceExtensions_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ff13297a632424a6abffea4dd75a36a75d128_003Ff9_003Fb35aae11_003FServiceCollectionHostedServiceExtensions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AStackFrameIterator_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fea51ca5e833244688d7ca912cfc70784d19c00_003F86_003F8b4aa64e_003FStackFrameIterator_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATaskAwaiter_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fea51ca5e833244688d7ca912cfc70784d19c00_003F10_003F04572d58_003FTaskAwaiter_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary> \ No newline at end of file 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