· 3 months ago · Jun 24, 2025, 03:35 PM
1 async def edit_creator(
2 self: 'TelegramClient',
3 entity: 'hints.EntityLike',
4 user: 'hints.EntityLike',
5 password: 'typing.Union[str, types.InputCheckPasswordSRP]',
6 ) -> types.Updates:
7 """
8 Transfer ownership to someone in a chat.
9
10 Raises an error if a wrong password was given
11 (e.g. you aren't the chat owner or the password is incorrect).
12
13 Unless otherwise stated, transferring will work in channels and megagroups.
14
15 Arguments
16 entity (`entity`):
17 The channel, megagroup or chat we own.
18
19 user (`entity`):
20 The new owner.
21
22 password (str or InputCheckPasswordSRP):
23 The 2FA password of the account.
24
25 Returns
26 The resulting :tl:`Updates` object.
27
28 Example
29 .. code-block:: python
30
31 await client.edit_creator(chat, user, password)
32 """
33 entity = await self.get_input_entity(entity)
34 user = await self.get_input_entity(user)
35
36 if not isinstance(password, types.InputCheckPasswordSRP):
37 pass_srp = await self(functions.account.GetPasswordRequest())
38 password = compute_check(pass_srp, password)
39
40 ty = helpers._entity_type(entity)
41
42 if ty == helpers._EntityType.CHANNEL:
43 return await self(functions.channels.EditCreatorRequest(
44 entity, user, password))
45
46 raise ValueError(
47 'You can only transfer ownership in groups and channels')