From 0f7eebd68327d5a953ec63754f46a72e02669945 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 30 Jun 2019 19:04:56 +0300 Subject: [PATCH] Add option to set related groups for created rooms --- example-config.yaml | 4 ++++ mautrix_telegram/config.py | 5 +++++ mautrix_telegram/portal.py | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/example-config.yaml b/example-config.yaml index e18008ca..1c80967e 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -60,6 +60,10 @@ appservice: bot_displayname: Telegram bridge bot bot_avatar: mxc://maunium.net/tJCRmUyJDsgRNgqhOgoiHWbX + # Community ID for bridged users (changes registration file) and rooms. + # Must be created manually. + community_id: false + # Authentication tokens for AS <-> HS communication. Autogenerated; do not modify. as_token: "This value is generated when generating the registration" hs_token: "This value is generated when generating the registration" diff --git a/mautrix_telegram/config.py b/mautrix_telegram/config.py index 2f3f6c26..4aa165fd 100644 --- a/mautrix_telegram/config.py +++ b/mautrix_telegram/config.py @@ -189,6 +189,8 @@ class Config(DictWithRecursion): copy("appservice.bot_displayname") copy("appservice.bot_avatar") + copy("appservice.community_id") + copy("appservice.as_token") copy("appservice.hs_token") @@ -352,3 +354,6 @@ class Config(DictWithRecursion): "sender_localpart": self["appservice.bot_username"], "rate_limited": False } + if self["appservice.community_id"]: + self._registration["namespaces"]["users"][0]["group_id"] \ + = self["appservice.community_id"] diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index 396dedea..5558867a 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -397,6 +397,11 @@ class Portal: "type": "m.room.power_levels", "content": power_levels, }] + if config["appservice.community_id"]: + initial_state.append({ + "type": "m.room.related_groups", + "content": {"groups": [config["appservice.community_id"]]}, + }) room_id = await self.main_intent.create_room(alias=alias, is_public=public, is_direct=direct, invitees=invites or [],