|
| 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 | +import pyrogram |
| 20 | +from pyrogram import raw |
| 21 | + |
| 22 | + |
| 23 | +class SetInactiveSessionTTL: |
| 24 | + async def set_inactive_session_ttl( |
| 25 | + self: "pyrogram.Client", |
| 26 | + inactive_session_ttl_days: int |
| 27 | + ): |
| 28 | + """Changes the period of inactivity after which sessions will automatically be terminated. |
| 29 | +
|
| 30 | + .. include:: /_includes/usable-by/users.rst |
| 31 | +
|
| 32 | + Parameters: |
| 33 | + inactive_session_ttl_days (``int``): |
| 34 | + New number of days of inactivity before sessions will be automatically terminated, 1-366 days. |
| 35 | +
|
| 36 | + Returns: |
| 37 | + ``bool``: On success, True is returned. |
| 38 | +
|
| 39 | + Example: |
| 40 | + .. code-block:: python |
| 41 | +
|
| 42 | + # Set inactive session ttl to 1 year |
| 43 | + await app.set_inactive_session_ttl(365) |
| 44 | + """ |
| 45 | + r = await self.invoke( |
| 46 | + raw.functions.account.SetAuthorizationTTL( |
| 47 | + authorization_ttl_days=inactive_session_ttl_days |
| 48 | + ) |
| 49 | + ) |
| 50 | + |
| 51 | + return r |
0 commit comments