Explorar o código

Add command to get group invite link

Tulir Asokan %!s(int64=3) %!d(string=hai) anos
pai
achega
4341909a5c
Modificáronse 1 ficheiros con 15 adicións e 0 borrados
  1. 15 0
      mautrix_signal/commands/signal.py

+ 15 - 0
mautrix_signal/commands/signal.py

@@ -78,6 +78,21 @@ async def pm(evt: CommandEvent) -> None:
     await evt.reply(f"Created a portal room with {_pill(puppet)} and invited you to it")
 
 
+@command_handler(needs_auth=True, management_only=False, help_section=SECTION_SIGNAL,
+                 help_text="Get the invite link to the current group")
+async def invite_link(evt: CommandEvent) -> EventID:
+    if not evt.is_portal:
+        return await evt.reply("This is not a portal room.")
+    group = await evt.bridge.signal.get_group(evt.sender.username, evt.portal.chat_id,
+                                              evt.portal.revision)
+    if not group:
+        await evt.reply("Failed to get group info")
+    elif not group.invite_link:
+        await evt.reply("Invite link not available")
+    else:
+        await evt.reply(group.invite_link)
+
+
 @command_handler(needs_auth=True, management_only=False, help_section=SECTION_SIGNAL,
                  help_text="View the safety number of a specific user",
                  help_args="[--qr] [_phone_]")