From 4d5b83f3595c9e500a7ec41cda8d3fbb61d9454a Mon Sep 17 00:00:00 2001 From: VityaSchel <59040542+VityaSchel@users.noreply.github.com> Date: Fri, 30 May 2025 07:24:40 +0400 Subject: [PATCH] Fixes #1009 --- mautrix_telegram/portal.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index a6a2c4c85..196dda943 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -65,6 +65,7 @@ from telethon.tl.custom import Dialog from telethon.tl.functions.channels import ( CreateChannelRequest, + EditAdminRequest, EditPhotoRequest, EditTitleRequest, InviteToChannelRequest, @@ -93,6 +94,7 @@ Channel, ChannelFull, Chat, + ChatAdminRights, ChatBannedRights, ChatEmpty, ChatFull, @@ -680,9 +682,14 @@ async def handle_matrix_invite( AddChatUserRequest(chat_id=self.tgid, user_id=puppet.tgid, fwd_limit=0) ) elif self.peer_type == "channel": - await invited_by.client( - InviteToChannelRequest(channel=self.peer, users=[puppet.tgid]) - ) + if not puppet.is_bot: + await invited_by.client( + InviteToChannelRequest(channel=self.peer, users=[puppet.tgid]) + ) + else: + await invited_by.client( + EditAdminRequest(channel=self.peer, user_id=puppet.tgid, admin_rights=ChatAdminRights(), rank="Bridge") + ) # We don't care if there are invites for private chat portals with the relaybot. elif not self.bot or self.tg_receiver != self.bot.tgid: raise RejectMatrixInvite("You can't invite additional users to private chats.")