From 79e972df85bb5ddb5e9601165141a99de7b0c310 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 6 Dec 2017 21:33:57 +0100 Subject: [PATCH] Move ACTIONS outside the method --- pyrogram/client/client.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 12902c3a..57133837 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -454,30 +454,30 @@ class Client: ) ) + ACTIONS = { + "cancel": types.SendMessageCancelAction, + "typing": types.SendMessageTypingAction, + "playing": types.SendMessageGamePlayAction, + "choose_contact": types.SendMessageChooseContactAction, + "upload_photo": types.SendMessageUploadPhotoAction, + "record_video": types.SendMessageRecordVideoAction, + "upload_video": types.SendMessageUploadVideoAction, + "record_audio": types.SendMessageRecordAudioAction, + "upload_audio": types.SendMessageUploadAudioAction, + "upload_document": types.SendMessageUploadDocumentAction, + "find_location": types.SendMessageGeoLocationAction, + "record_video_note": types.SendMessageRecordRoundAction, + "upload_video_note": types.SendMessageUploadRoundAction, + } + def send_chat_action(self, chat_id: int or str, action: str, progress: int = 0): - actions = { - "cancel": types.SendMessageCancelAction, - "typing": types.SendMessageTypingAction, - "playing": types.SendMessageGamePlayAction, - "choose_contact": types.SendMessageChooseContactAction, - "upload_photo": types.SendMessageUploadPhotoAction, - "record_video": types.SendMessageRecordVideoAction, - "upload_video": types.SendMessageUploadVideoAction, - "record_audio": types.SendMessageRecordAudioAction, - "upload_audio": types.SendMessageUploadAudioAction, - "upload_document": types.SendMessageUploadDocumentAction, - "find_location": types.SendMessageGeoLocationAction, - "record_video_note": types.SendMessageRecordRoundAction, - "upload_video_note": types.SendMessageUploadRoundAction, - } - return self.send( functions.messages.SetTyping( peer=self.resolve_peer(chat_id), - action=actions.get( + action=self.ACTIONS.get( action.lower() )(progress=progress) )