Skip to content

Commit 593d17f

Browse files
Add set_inactive_session_ttl method
1 parent 1d8e12b commit 593d17f

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

compiler/docs/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ def get_title_list(s: str) -> list:
560560
set_privacy
561561
get_privacy
562562
set_global_privacy_settings
563+
set_inactive_session_ttl
563564
get_global_privacy_settings
564565
"""
565566
)

pyrogram/methods/account/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from .get_privacy import GetPrivacy
2222
from .set_account_ttl import SetAccountTTL
2323
from .set_global_privacy_settings import SetGlobalPrivacySettings
24+
from .set_inactive_session_ttl import SetInactiveSessionTTL
2425
from .set_privacy import SetPrivacy
2526

2627
class Account(
@@ -29,6 +30,7 @@ class Account(
2930
GetPrivacy,
3031
SetAccountTTL,
3132
SetGlobalPrivacySettings,
33+
SetInactiveSessionTTL,
3234
SetPrivacy
3335
):
3436
pass
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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

Comments
 (0)