|
| 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 List, Optional, Union |
| 20 | + |
| 21 | +import pyrogram |
| 22 | +from pyrogram import raw |
| 23 | + |
| 24 | + |
| 25 | +class SetManagedBotAccessSettings: |
| 26 | + async def set_managed_bot_access_settings( |
| 27 | + self: "pyrogram.Client", |
| 28 | + user_id: Union[int, str], |
| 29 | + is_access_restricted: bool, |
| 30 | + added_user_ids: Optional[List[Union[int, str]]] = None, |
| 31 | + ) -> bool: |
| 32 | + """Use this method to get the access settings of a managed bot. |
| 33 | +
|
| 34 | + .. include:: /_includes/usable-by/users-bots.rst |
| 35 | +
|
| 36 | + Parameters: |
| 37 | + user_id (``int`` | ``str``): |
| 38 | + Unique identifier (int) or username (str) of the managed bot whose access settings will be changed. |
| 39 | +
|
| 40 | + is_access_restricted (``bool``): |
| 41 | + Pass True, if only selected users can access the bot. |
| 42 | + The bot's owner can always access it. |
| 43 | +
|
| 44 | + added_user_ids (List of ``int`` | ``str``, *optional*): |
| 45 | + List of up to 10 identifiers of users who will have access to the bot in addition to its owner. |
| 46 | + Ignored if is_access_restricted is False. |
| 47 | +
|
| 48 | + Returns: |
| 49 | + ``bool``: On success, True is returned. |
| 50 | + """ |
| 51 | + if is_access_restricted is False: |
| 52 | + added_user_ids = None |
| 53 | + |
| 54 | + return await self.invoke( |
| 55 | + raw.functions.bots.EditAccessSettings( |
| 56 | + bot=await self.resolve_peer(user_id), |
| 57 | + restricted=is_access_restricted, |
| 58 | + add_users=[await self.resolve_peer(i) for i in added_user_ids] if added_user_ids is not None else None, |
| 59 | + ) |
| 60 | + ) |
0 commit comments