-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement handle_puppet_group_invite
- Loading branch information
Showing
7 changed files
with
118 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# mautrix-signal - A Matrix-Signal puppeting bridge | ||
# Copyright (C) 2021 Tulir Asokan | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
from __future__ import annotations | ||
|
||
from mautrix.appservice import IntentAPI | ||
from mautrix.types import ContentURI, EventType, JoinRule, PowerLevelStateEventContent, RoomID | ||
|
||
|
||
async def get_initial_state( | ||
intent: IntentAPI, room_id: RoomID | ||
) -> tuple[ | ||
str | None, | ||
str | None, | ||
PowerLevelStateEventContent | None, | ||
bool, | ||
ContentURI | None, | ||
JoinRule | None, | ||
]: | ||
state = await intent.get_state(room_id) | ||
title: str | None = None | ||
about: str | None = None | ||
levels: PowerLevelStateEventContent | None = None | ||
encrypted: bool = False | ||
avatar_url: ContentURI | None = None | ||
join_rule: JoinRule | None = None | ||
for event in state: | ||
try: | ||
if event.type == EventType.ROOM_NAME: | ||
title = event.content.name | ||
elif event.type == EventType.ROOM_TOPIC: | ||
about = event.content.topic | ||
elif event.type == EventType.ROOM_POWER_LEVELS: | ||
levels = event.content | ||
elif event.type == EventType.ROOM_CANONICAL_ALIAS: | ||
title = title or event.content.canonical_alias | ||
elif event.type == EventType.ROOM_ENCRYPTION: | ||
encrypted = True | ||
elif event.type == EventType.ROOM_AVATAR: | ||
avatar_url = event.content.url | ||
elif event.type == EventType.ROOM_JOIN_RULES: | ||
join_rule = event.content.join_rule | ||
except KeyError: | ||
# Some state event probably has empty content | ||
pass | ||
return title, about, levels, encrypted, avatar_url, join_rule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters