about summary refs log tree commit diff
path: root/MiniUtils/Commands/JoinCommand.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-05-18 22:52:39 +0200
committerRory& <root@rory.gay>2025-05-18 22:52:39 +0200
commit82e5660b63ea6466e22f855fe524b288b62da7f9 (patch)
treeb9aa304da0002c2b85d4063a84f4d6e59e8f9008 /MiniUtils/Commands/JoinCommand.cs
parentAdd more commands (diff)
downloadMiniUtils-master.tar.xz
More stuff HEAD master
Diffstat (limited to 'MiniUtils/Commands/JoinCommand.cs')
-rw-r--r--MiniUtils/Commands/JoinCommand.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/MiniUtils/Commands/JoinCommand.cs b/MiniUtils/Commands/JoinCommand.cs
new file mode 100644

index 0000000..1ed51b6 --- /dev/null +++ b/MiniUtils/Commands/JoinCommand.cs
@@ -0,0 +1,26 @@ +using LibMatrix.EventTypes.Spec.State.RoomInfo; +using LibMatrix.Services; +using LibMatrix.Utilities.Bot.Interfaces; + +namespace MiniUtils.Commands; + +public class JoinCommand(MiniUtilsConfiguration config, HomeserverProviderService hsProvider) : ICommand { + public string Name => "join"; + + public string[]? Aliases => []; + + public string Description => "Redact all user's events"; + + public bool Unlisted => false; + public async Task Invoke(CommandContext ctx) { + var profile = config.ExternalProfiles[ctx.Args[0]]; + var rhs = await hsProvider.GetAuthenticatedWithToken(profile.Homeserver, profile.AccessToken, enableServer: false, useGeneric: true); + + var joinRules = await ctx.Room.GetJoinRuleAsync(); + if (joinRules?.JoinRule is not RoomJoinRulesEventContent.JoinRules.Public) { + await ctx.Room.InviteUserAsync(rhs.UserId); + } + + _ = rhs.GetRoom(ctx.Room.RoomId).JoinAsync([ctx.Homeserver.ServerName]); + } +} \ No newline at end of file