|
| 1 | +# Pyrogram - Telegram MTProto API Client Library for Python |
| 2 | +# Copyright (C) 2017-2019 Dan Tès <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, List |
| 20 | + |
| 21 | +from pyrogram.api import functions, types |
| 22 | +from ...ext import BaseClient |
| 23 | + |
| 24 | + |
| 25 | +class UnarchiveChats(BaseClient): |
| 26 | + def unarchive_chats( |
| 27 | + self, |
| 28 | + chat_ids: Union[int, str, List[Union[int, str]]], |
| 29 | + ) -> bool: |
| 30 | + """Unarchive one or more chats. |
| 31 | +
|
| 32 | + Parameters: |
| 33 | + chat_ids (``int`` | ``str`` | List[``int``, ``str``]): |
| 34 | + Unique identifier (int) or username (str) of the target chat. |
| 35 | + You can also pass a list of ids (int) or usernames (str). |
| 36 | +
|
| 37 | + Returns: |
| 38 | + ``bool``: On success, True is returned. |
| 39 | +
|
| 40 | + Raises: |
| 41 | + RPCError: In case of a Telegram RPC error. |
| 42 | + """ |
| 43 | + |
| 44 | + if not isinstance(chat_ids, list): |
| 45 | + chat_ids = [chat_ids] |
| 46 | + |
| 47 | + self.send( |
| 48 | + functions.folders.EditPeerFolders( |
| 49 | + folder_peers=[ |
| 50 | + types.InputFolderPeer( |
| 51 | + peer=self.resolve_peer(chat), |
| 52 | + folder_id=0 |
| 53 | + ) for chat in chat_ids |
| 54 | + ] |
| 55 | + ) |
| 56 | + ) |
| 57 | + |
| 58 | + return True |
0 commit comments