mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 21:07:59 +00:00
Made ChatAction an Enum
This commit is contained in:
parent
e6b4f0e743
commit
72e95fd322
@ -15,12 +15,13 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
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() <pyrogram.Client.send_chat_action>`.
|
||||
"""
|
||||
|
||||
|
@ -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 <pyrogram.Error>`
|
||||
"""
|
||||
# Resolve Enum type
|
||||
action = action.value if isinstance(action, ChatAction) else action
|
||||
|
||||
if "Upload" in action.__name__:
|
||||
action = action(progress)
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user