Преглед изворни кода

Add command to get group invite link

Tulir Asokan пре 3 година
родитељ
комит
4341909a5c
1 измењених фајлова са 15 додато и 0 уклоњено
  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_]")