diff --git a/pyrogram/client/chat_action.py b/pyrogram/client/chat_action.py index 95bffb8e..86661f00 100644 --- a/pyrogram/client/chat_action.py +++ b/pyrogram/client/chat_action.py @@ -15,12 +15,13 @@ # # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . +from enum import Enum from pyrogram.api import types -class ChatAction: - """This class provides a convenient access to all Chat Actions available. +class ChatAction(Enum): + """This enumeration provides a convenient access to all Chat Actions available. Chat Actions are intended to be used with :meth:`send_chat_action() `. """ diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 31bb0e01..e1f218ca 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -38,6 +38,7 @@ from signal import signal, SIGINT, SIGTERM, SIGABRT from threading import Event, Thread import pyrogram +from pyrogram import ChatAction from pyrogram.api import functions, types from pyrogram.api.core import Object from pyrogram.api.errors import ( @@ -2502,7 +2503,7 @@ class Client: def send_chat_action(self, chat_id: int or str, - action: callable, + action: ChatAction, progress: int = 0): """Use this method when you need to tell the other party that something is happening on your side. @@ -2527,6 +2528,9 @@ class Client: Raises: :class:`Error ` """ + # Resolve Enum type + action = action.value if isinstance(action, ChatAction) else action + if "Upload" in action.__name__: action = action(progress) else: