2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Made ChatAction an Enum

This commit is contained in:
JosXa 2018-04-30 16:03:18 +02:00
parent e6b4f0e743
commit 72e95fd322
2 changed files with 8 additions and 3 deletions

View File

@ -15,12 +15,13 @@
# #
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum
from pyrogram.api import types from pyrogram.api import types
class ChatAction: class ChatAction(Enum):
"""This class provides a convenient access to all Chat Actions available. """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>`. Chat Actions are intended to be used with :meth:`send_chat_action() <pyrogram.Client.send_chat_action>`.
""" """

View File

@ -38,6 +38,7 @@ from signal import signal, SIGINT, SIGTERM, SIGABRT
from threading import Event, Thread from threading import Event, Thread
import pyrogram import pyrogram
from pyrogram import ChatAction
from pyrogram.api import functions, types from pyrogram.api import functions, types
from pyrogram.api.core import Object from pyrogram.api.core import Object
from pyrogram.api.errors import ( from pyrogram.api.errors import (
@ -2502,7 +2503,7 @@ class Client:
def send_chat_action(self, def send_chat_action(self,
chat_id: int or str, chat_id: int or str,
action: callable, action: ChatAction,
progress: int = 0): progress: int = 0):
"""Use this method when you need to tell the other party that something is happening on your side. """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: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
# Resolve Enum type
action = action.value if isinstance(action, ChatAction) else action
if "Upload" in action.__name__: if "Upload" in action.__name__:
action = action(progress) action = action(progress)
else: else: