From be37e3b46c5a917695476684503a2779469dc235 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 24 Apr 2022 11:56:07 +0200 Subject: [PATCH] Rename enum MessageService to MessageServiceType --- docs/source/api/enums/MessageService.rst | 8 ---- docs/source/api/enums/MessageServiceType.rst | 8 ++++ docs/source/api/enums/index.rst | 4 +- pyrogram/enums/__init__.py | 2 +- ...age_service.py => message_service_type.py} | 4 +- pyrogram/types/messages_and_media/message.py | 40 +++++++++---------- 6 files changed, 33 insertions(+), 33 deletions(-) delete mode 100644 docs/source/api/enums/MessageService.rst create mode 100644 docs/source/api/enums/MessageServiceType.rst rename pyrogram/enums/{message_service.py => message_service_type.py} (93%) diff --git a/docs/source/api/enums/MessageService.rst b/docs/source/api/enums/MessageService.rst deleted file mode 100644 index 7b7ee4e2..00000000 --- a/docs/source/api/enums/MessageService.rst +++ /dev/null @@ -1,8 +0,0 @@ -MessageService -============== - -.. autoclass:: pyrogram.enums.MessageService() - :members: - -.. raw:: html - :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/MessageServiceType.rst b/docs/source/api/enums/MessageServiceType.rst new file mode 100644 index 00000000..2de56818 --- /dev/null +++ b/docs/source/api/enums/MessageServiceType.rst @@ -0,0 +1,8 @@ +MessageServiceType +================== + +.. autoclass:: pyrogram.enums.MessageServiceType() + :members: + +.. raw:: html + :file: ./cleanup.html \ No newline at end of file diff --git a/docs/source/api/enums/index.rst b/docs/source/api/enums/index.rst index 12b1fac1..bd9f8b1d 100644 --- a/docs/source/api/enums/index.rst +++ b/docs/source/api/enums/index.rst @@ -20,7 +20,7 @@ to apply only a valid value among the expected ones. ChatType MessageEntityType MessageMediaType - MessageService + MessageServiceType MessagesFilter ParseMode PollType @@ -38,7 +38,7 @@ to apply only a valid value among the expected ones. ChatType MessageEntityType MessageMediaType - MessageService + MessageServiceType MessagesFilter ParseMode PollType diff --git a/pyrogram/enums/__init__.py b/pyrogram/enums/__init__.py index acdc5233..f847b3cf 100644 --- a/pyrogram/enums/__init__.py +++ b/pyrogram/enums/__init__.py @@ -23,7 +23,7 @@ from .chat_members_filter import ChatMembersFilter from .chat_type import ChatType from .message_entity_type import MessageEntityType from .message_media_type import MessageMediaType -from .message_service import MessageService +from .message_service_type import MessageServiceType from .messages_filter import MessagesFilter from .next_code_type import NextCodeType from .parse_mode import ParseMode diff --git a/pyrogram/enums/message_service.py b/pyrogram/enums/message_service_type.py similarity index 93% rename from pyrogram/enums/message_service.py rename to pyrogram/enums/message_service_type.py index 636e6db5..8a60e29e 100644 --- a/pyrogram/enums/message_service.py +++ b/pyrogram/enums/message_service_type.py @@ -21,8 +21,8 @@ from enum import auto from .auto_name import AutoName -class MessageService(AutoName): - """Message service enumeration used in :obj:`~pyrogram.types.Message`.""" +class MessageServiceType(AutoName): + """Message service type enumeration used in :obj:`~pyrogram.types.Message`.""" NEW_CHAT_MEMBERS = auto() "New members join" diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 9f0cf8a3..68f92c3c 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -113,7 +113,7 @@ class Message(Object, Update): The message is empty. A message can be empty in case it was deleted or you tried to retrieve a message that doesn't exist yet. - service (:obj:`~pyrogram.enums.MessageService`, *optional*): + service (:obj:`~pyrogram.enums.MessageServiceType`, *optional*): The message is a service message. This field will contain the enumeration type of the service message. You can use ``service = getattr(message, message.service.value)`` to access the service message. @@ -321,10 +321,10 @@ class Message(Object, Update): reply_to_message: "Message" = None, mentioned: bool = None, empty: bool = None, - service: "enums.MessageService" = None, + service: "enums.MessageServiceType" = None, scheduled: bool = None, from_scheduled: bool = None, - media: str = None, + media: "enums.MessageMediaType" = None, edit_date: datetime = None, media_group_id: str = None, author_signature: str = None, @@ -502,50 +502,50 @@ class Message(Object, Update): if isinstance(action, raw.types.MessageActionChatAddUser): new_chat_members = [types.User._parse(client, users[i]) for i in action.users] - service_type = enums.MessageService.NEW_CHAT_MEMBERS + service_type = enums.MessageServiceType.NEW_CHAT_MEMBERS elif isinstance(action, raw.types.MessageActionChatJoinedByLink): new_chat_members = [types.User._parse(client, users[utils.get_raw_peer_id(message.from_id)])] - service_type = enums.MessageService.NEW_CHAT_MEMBERS + service_type = enums.MessageServiceType.NEW_CHAT_MEMBERS elif isinstance(action, raw.types.MessageActionChatDeleteUser): left_chat_member = types.User._parse(client, users[action.user_id]) - service_type = enums.MessageService.LEFT_CHAT_MEMBERS + service_type = enums.MessageServiceType.LEFT_CHAT_MEMBERS elif isinstance(action, raw.types.MessageActionChatEditTitle): new_chat_title = action.title - service_type = enums.MessageService.NEW_CHAT_TITLE + service_type = enums.MessageServiceType.NEW_CHAT_TITLE elif isinstance(action, raw.types.MessageActionChatDeletePhoto): delete_chat_photo = True - service_type = enums.MessageService.DELETE_CHAT_PHOTO + service_type = enums.MessageServiceType.DELETE_CHAT_PHOTO elif isinstance(action, raw.types.MessageActionChatMigrateTo): migrate_to_chat_id = action.channel_id - service_type = enums.MessageService.MIGRATE_TO_CHAT_ID + service_type = enums.MessageServiceType.MIGRATE_TO_CHAT_ID elif isinstance(action, raw.types.MessageActionChannelMigrateFrom): migrate_from_chat_id = action.chat_id - service_type = enums.MessageService.MIGRATE_FROM_CHAT_ID + service_type = enums.MessageServiceType.MIGRATE_FROM_CHAT_ID elif isinstance(action, raw.types.MessageActionChatCreate): group_chat_created = True - service_type = enums.MessageService.GROUP_CHAT_CREATED + service_type = enums.MessageServiceType.GROUP_CHAT_CREATED elif isinstance(action, raw.types.MessageActionChannelCreate): channel_chat_created = True - service_type = enums.MessageService.CHANNEL_CHAT_CREATED + service_type = enums.MessageServiceType.CHANNEL_CHAT_CREATED elif isinstance(action, raw.types.MessageActionChatEditPhoto): new_chat_photo = types.Photo._parse(client, action.photo) - service_type = enums.MessageService.NEW_CHAT_PHOTO + service_type = enums.MessageServiceType.NEW_CHAT_PHOTO elif isinstance(action, raw.types.MessageActionGroupCallScheduled): video_chat_scheduled = types.VideoChatScheduled._parse(action) - service_type = enums.MessageService.VIDEO_CHAT_SCHEDULED + service_type = enums.MessageServiceType.VIDEO_CHAT_SCHEDULED elif isinstance(action, raw.types.MessageActionGroupCall): if action.duration: video_chat_ended = types.VideoChatEnded._parse(action) - service_type = enums.MessageService.VIDEO_CHAT_ENDED + service_type = enums.MessageServiceType.VIDEO_CHAT_ENDED else: video_chat_started = types.VideoChatStarted() - service_type = enums.MessageService.VIDEO_CHAT_STARTED + service_type = enums.MessageServiceType.VIDEO_CHAT_STARTED elif isinstance(action, raw.types.MessageActionInviteToGroupCall): video_chat_members_invited = types.VideoChatMembersInvited._parse(client, action, users) - service_type = enums.MessageService.VIDEO_CHAT_MEMBERS_INVITED + service_type = enums.MessageServiceType.VIDEO_CHAT_MEMBERS_INVITED elif isinstance(action, raw.types.MessageActionWebViewDataSentMe): web_app_data = types.WebAppData._parse(action) - service_type = enums.MessageService.WEB_APP_DATA + service_type = enums.MessageServiceType.WEB_APP_DATA from_user = types.User._parse(client, users.get(user_id, None)) sender_chat = types.Chat._parse(client, message, users, chats, is_chat=False) if not from_user else None @@ -583,7 +583,7 @@ class Message(Object, Update): replies=0 ) - parsed_message.service = enums.MessageService.PINNED_MESSAGE + parsed_message.service = enums.MessageServiceType.PINNED_MESSAGE except MessageIdsEmpty: pass @@ -598,7 +598,7 @@ class Message(Object, Update): replies=0 ) - parsed_message.service = enums.MessageService.GAME_HIGH_SCORE + parsed_message.service = enums.MessageServiceType.GAME_HIGH_SCORE except MessageIdsEmpty: pass