Skip to content

Commit

Permalink
Add terminate_all_other_sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe committed Aug 2, 2024
1 parent 7ee5606 commit b6fad53
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions compiler/docs/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def get_title_list(s: str) -> list:
get_me
get_active_sessions
terminate_session
terminate_all_other_sessions
""",
messages="""
Messages
Expand Down
2 changes: 1 addition & 1 deletion docs/source/releases/changes-in-this-fork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If you found any issue or have any suggestions, feel free to make `an issue <htt
+------------------------+

- Updated :obj:`~pyrogram.filters.via_bot`, to optionally support filtering invalid bot ``user_id``.
- Added the :meth:`~pyrogram.Client.get_active_sessions`, :meth:`~pyrogram.Client.terminate_session`, :meth:`~pyrogram.types.ActiveSession.terminate`.
- Added the :meth:`~pyrogram.Client.get_active_sessions`, :meth:`~pyrogram.Client.terminate_session`, :meth:`~pyrogram.types.ActiveSession.terminate`, and :meth:`~pyrogram.Client.terminate_all_other_sessions`.
- Added the ``is_automatic_forward`` to the :obj:`~pyrogram.types.Message`.
- Added the parameters ``offset_id`` to the :meth:`~pyrogram.Client.search_messages` and the parameters ``min_date``, ``max_date``, ``min_id``, ``max_id``, ``saved_messages_topic_id`` to the :meth:`~pyrogram.Client.search_messages_count`.
- Dynamic session ReStart + restart optimizations (`#56 <https://github.com/TelegramPlayGround/pyrogram/pull/56>`__)
Expand Down
2 changes: 2 additions & 0 deletions pyrogram/methods/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from .sign_in_bot import SignInBot
from .sign_up import SignUp
from .terminate import Terminate
from .terminate_all_other_sessions import TerminateAllOtherSessions
from .terminate_session import TerminateSession


Expand All @@ -52,6 +53,7 @@ class Auth(
SignInBot,
SignUp,
Terminate,
TerminateAllOtherSessions,
TerminateSession,
):
pass
40 changes: 40 additions & 0 deletions pyrogram/methods/auth/terminate_all_other_sessions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

import pyrogram
from pyrogram import raw


class TerminateAllOtherSessions:
async def terminate_all_other_sessions(
self: "pyrogram.Client"
) -> bool:
"""Terminates all other sessions of the current user.
.. include:: /_includes/usable-by/users.rst
Returns:
``bool``: On success, in case the session is destroyed, True is returned. Otherwise, False is returned.
Raises:
RPCError: In case of a Telegram RPC error.
"""
return await self.invoke(
raw.functions.auth.ResetAuthorizations()
)

0 comments on commit b6fad53

Please sign in to comment.