|
| 1 | +# Pyrogram - Telegram MTProto API Client Library for Python |
| 2 | +# Copyright (C) 2017-present Dan <https://github.com/delivrance> |
| 3 | +# |
| 4 | +# This file is part of Pyrogram. |
| 5 | +# |
| 6 | +# Pyrogram is free software: you can redistribute it and/or modify |
| 7 | +# it under the terms of the GNU Lesser General Public License as published |
| 8 | +# by the Free Software Foundation, either version 3 of the License, or |
| 9 | +# (at your option) any later version. |
| 10 | +# |
| 11 | +# Pyrogram is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +# GNU Lesser General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU Lesser General Public License |
| 17 | +# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + |
| 19 | +from typing import Union |
| 20 | + |
| 21 | +import pyrogram |
| 22 | +from pyrogram import raw |
| 23 | + |
| 24 | + |
| 25 | +class EditCreator: |
| 26 | + async def edit_creator( |
| 27 | + self: "pyrogram.Client", |
| 28 | + chat_id: Union[int, str], |
| 29 | + user_id: Union[int, str], |
| 30 | + password: str, |
| 31 | + ) -> "raw.base.Updates": |
| 32 | + """Transfer channel ownership to another user. |
| 33 | +
|
| 34 | + .. include:: /_includes/usable-by/users.rst |
| 35 | +
|
| 36 | + Parameters: |
| 37 | + chat_id (``int`` | ``str``): |
| 38 | + Unique identifier (int) or username (str) of the target channel. |
| 39 | +
|
| 40 | + user_id (``int`` | ``str``): |
| 41 | + Unique identifier (int) or username (str) of the user that will become the new creator. |
| 42 | +
|
| 43 | + password (``str``): |
| 44 | + Your 2FA password (required for ownership transfer). |
| 45 | +
|
| 46 | + Returns: |
| 47 | + :obj:`~pyrogram.raw.base.Updates`: On success. |
| 48 | +
|
| 49 | + Example: |
| 50 | + .. code-block:: python |
| 51 | +
|
| 52 | + await app.edit_creator(chat_id, user_id, "my_password") |
| 53 | + """ |
| 54 | + r = await self.invoke( |
| 55 | + raw.functions.channels.EditCreator( |
| 56 | + channel=await self.resolve_peer(chat_id), |
| 57 | + user_id=await self.resolve_peer(user_id), |
| 58 | + password=raw.types.InputCheckPasswordSRP( |
| 59 | + srp_id=0, |
| 60 | + A=b"", |
| 61 | + M1=b"", |
| 62 | + ), |
| 63 | + ) |
| 64 | + ) |
| 65 | + |
| 66 | + for i in r.updates: |
| 67 | + if isinstance(i, raw.types.UpdateEditChannelMessage): |
| 68 | + return True |
| 69 | + |
| 70 | + return r |
0 commit comments