diff --git a/pyrogram/methods/chats/iter_dialogs.py b/pyrogram/methods/chats/iter_dialogs.py index 2584d98d..4553e3d4 100644 --- a/pyrogram/methods/chats/iter_dialogs.py +++ b/pyrogram/methods/chats/iter_dialogs.py @@ -93,7 +93,7 @@ class IterDialogs(Scaffold): last = dialogs[-1] - offset_id = last.top_message.message_id + offset_id = last.top_message.id offset_date = last.top_message.date offset_peer = await self.resolve_peer(last.chat.id) diff --git a/pyrogram/methods/messages/iter_history.py b/pyrogram/methods/messages/iter_history.py index b9dd2009..c5eda288 100644 --- a/pyrogram/methods/messages/iter_history.py +++ b/pyrogram/methods/messages/iter_history.py @@ -89,7 +89,7 @@ class IterHistory(Scaffold): if not messages: return - offset_id = messages[-1].message_id + (1 if reverse else 0) + offset_id = messages[-1].id + (1 if reverse else 0) for message in messages: yield message diff --git a/pyrogram/methods/messages/search_global.py b/pyrogram/methods/messages/search_global.py index 2c22b26f..6dff7bf0 100644 --- a/pyrogram/methods/messages/search_global.py +++ b/pyrogram/methods/messages/search_global.py @@ -102,7 +102,7 @@ class SearchGlobal(Scaffold): offset_date = last.date offset_peer = await self.resolve_peer(last.chat.id) - offset_id = last.message_id + offset_id = last.id for message in messages: yield message diff --git a/pyrogram/methods/messages/send_message.py b/pyrogram/methods/messages/send_message.py index a094ba92..34063625 100644 --- a/pyrogram/methods/messages/send_message.py +++ b/pyrogram/methods/messages/send_message.py @@ -149,7 +149,7 @@ class SendMessage(Scaffold): ) return types.Message( - message_id=r.id, + id=r.id, chat=types.Chat( id=peer_id, type=enums.ChatType.PRIVATE, diff --git a/pyrogram/types/bots_and_keyboards/callback_query.py b/pyrogram/types/bots_and_keyboards/callback_query.py index e5db8723..436b6076 100644 --- a/pyrogram/types/bots_and_keyboards/callback_query.py +++ b/pyrogram/types/bots_and_keyboards/callback_query.py @@ -203,7 +203,7 @@ class CallbackQuery(Object, Update): if self.inline_message_id is None: return await self._client.edit_message_text( chat_id=self.message.chat.id, - message_id=self.message.message_id, + message_id=self.message.id, text=text, parse_mode=parse_mode, disable_web_page_preview=disable_web_page_preview, @@ -274,7 +274,7 @@ class CallbackQuery(Object, Update): if self.inline_message_id is None: return await self._client.edit_message_media( chat_id=self.message.chat.id, - message_id=self.message.message_id, + message_id=self.message.id, media=media, reply_markup=reply_markup ) @@ -307,7 +307,7 @@ class CallbackQuery(Object, Update): if self.inline_message_id is None: return await self._client.edit_message_reply_markup( chat_id=self.message.chat.id, - message_id=self.message.message_id, + message_id=self.message.id, reply_markup=reply_markup ) else: diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 86c340ae..56ffd691 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -60,7 +60,7 @@ class Message(Object, Update): """A message. Parameters: - message_id (``int``): + id (``int``): Unique message identifier inside this chat. from_user (:obj:`~pyrogram.types.User`, *optional*): @@ -302,7 +302,7 @@ class Message(Object, Update): self, *, client: "pyrogram.Client" = None, - message_id: int, + id: int, from_user: "types.User" = None, sender_chat: "types.Chat" = None, date: datetime = None, @@ -376,7 +376,7 @@ class Message(Object, Update): ): super().__init__(client) - self.message_id = message_id + self.id = id self.from_user = from_user self.sender_chat = sender_chat self.date = date @@ -453,7 +453,7 @@ class Message(Object, Update): replies: int = 1 ): if isinstance(message, raw.types.MessageEmpty): - return Message(message_id=message.id, empty=True, client=client) + return Message(id=message.id, empty=True, client=client) from_id = utils.get_raw_peer_id(message.from_id) peer_id = utils.get_raw_peer_id(message.peer_id) @@ -542,7 +542,7 @@ class Message(Object, Update): sender_chat = types.Chat._parse(client, message, users, chats, is_chat=False) if not from_user else None parsed_message = Message( - message_id=message.id, + id=message.id, date=utils.timestamp_to_datetime(message.date), chat=types.Chat._parse(client, message, users, chats, is_chat=True), from_user=from_user, @@ -739,7 +739,7 @@ class Message(Object, Update): for r in message.reactions.results] if message.reactions else None parsed_message = Message( - message_id=message.id, + id=message.id, date=utils.timestamp_to_datetime(message.date), chat=types.Chat._parse(client, message, users, chats, is_chat=True), from_user=from_user, @@ -823,9 +823,9 @@ class Message(Object, Update): self.chat.type in (enums.ChatType.GROUP, enums.ChatType.SUPERGROUP, enums.ChatType.CHANNEL) and self.chat.username ): - return f"https://t.me/{self.chat.username}/{self.message_id}" + return f"https://t.me/{self.chat.username}/{self.id}" else: - return f"https://t.me/c/{utils.get_channel_id(self.chat.id)}/{self.message_id}" + return f"https://t.me/c/{utils.get_channel_id(self.chat.id)}/{self.id}" async def get_media_group(self) -> List["types.Message"]: """Bound method *get_media_group* of :obj:`~pyrogram.types.Message`. @@ -836,7 +836,7 @@ class Message(Object, Update): client.get_media_group( chat_id=message.chat.id, - message_id=message.message_id + message_id=message.id ) Example: @@ -853,7 +853,7 @@ class Message(Object, Update): return await self._client.get_media_group( chat_id=self.chat.id, - message_id=self.message_id + message_id=self.id ) async def reply_text( @@ -880,7 +880,7 @@ class Message(Object, Update): client.send_message( chat_id=message.chat.id, text="hello", - reply_to_message_id=message.message_id + reply_to_message_id=message.id ) Example: @@ -934,7 +934,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_message( chat_id=self.chat.id, @@ -1071,7 +1071,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_animation( chat_id=self.chat.id, @@ -1210,7 +1210,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_audio( chat_id=self.chat.id, @@ -1302,7 +1302,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_cached_media( chat_id=self.chat.id, @@ -1425,7 +1425,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_contact( chat_id=self.chat.id, @@ -1561,7 +1561,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_document( chat_id=self.chat.id, @@ -1639,7 +1639,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_game( chat_id=self.chat.id, @@ -1703,7 +1703,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_inline_bot_result( chat_id=self.chat.id, @@ -1777,7 +1777,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_location( chat_id=self.chat.id, @@ -1840,7 +1840,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_media_group( chat_id=self.chat.id, @@ -1956,7 +1956,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_photo( chat_id=self.chat.id, @@ -2060,7 +2060,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_poll( chat_id=self.chat.id, @@ -2164,7 +2164,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_sticker( chat_id=self.chat.id, @@ -2259,7 +2259,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_venue( chat_id=self.chat.id, @@ -2404,7 +2404,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_video( chat_id=self.chat.id, @@ -2528,7 +2528,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_video_note( chat_id=self.chat.id, @@ -2648,7 +2648,7 @@ class Message(Object, Update): quote = self.chat.type != "private" if reply_to_message_id is None and quote: - reply_to_message_id = self.message_id + reply_to_message_id = self.id return await self._client.send_voice( chat_id=self.chat.id, @@ -2682,7 +2682,7 @@ class Message(Object, Update): client.edit_message_text( chat_id=message.chat.id, - message_id=message.message_id, + message_id=message.id, text="hello" ) @@ -2716,7 +2716,7 @@ class Message(Object, Update): """ return await self._client.edit_message_text( chat_id=self.chat.id, - message_id=self.message_id, + message_id=self.id, text=text, parse_mode=parse_mode, entities=entities, @@ -2741,7 +2741,7 @@ class Message(Object, Update): client.edit_message_caption( chat_id=message.chat.id, - message_id=message.message_id, + message_id=message.id, caption="hello" ) @@ -2772,7 +2772,7 @@ class Message(Object, Update): """ return await self._client.edit_message_caption( chat_id=self.chat.id, - message_id=self.message_id, + message_id=self.id, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, @@ -2792,7 +2792,7 @@ class Message(Object, Update): client.edit_message_media( chat_id=message.chat.id, - message_id=message.message_id, + message_id=message.id, media=media ) @@ -2816,7 +2816,7 @@ class Message(Object, Update): """ return await self._client.edit_message_media( chat_id=self.chat.id, - message_id=self.message_id, + message_id=self.id, media=media, reply_markup=reply_markup ) @@ -2830,7 +2830,7 @@ class Message(Object, Update): client.edit_message_reply_markup( chat_id=message.chat.id, - message_id=message.message_id, + message_id=message.id, reply_markup=inline_reply_markup ) @@ -2852,7 +2852,7 @@ class Message(Object, Update): """ return await self._client.edit_message_reply_markup( chat_id=self.chat.id, - message_id=self.message_id, + message_id=self.id, reply_markup=reply_markup ) @@ -2871,7 +2871,7 @@ class Message(Object, Update): client.forward_messages( chat_id=chat_id, from_chat_id=message.chat.id, - message_ids=message.message_id + message_ids=message.id ) Example: @@ -2901,7 +2901,7 @@ class Message(Object, Update): return await self._client.forward_messages( chat_id=chat_id, from_chat_id=self.chat.id, - message_ids=self.message_id, + message_ids=self.id, disable_notification=disable_notification, schedule_date=schedule_date ) @@ -2932,7 +2932,7 @@ class Message(Object, Update): client.copy_message( chat_id=chat_id, from_chat_id=message.chat.id, - message_id=message.message_id + message_id=message.id ) Example: @@ -2985,10 +2985,10 @@ class Message(Object, Update): """ if self.service: log.warning(f"Service messages cannot be copied. " - f"chat_id: {self.chat.id}, message_id: {self.message_id}") + f"chat_id: {self.chat.id}, message_id: {self.id}") elif self.game and not await self._client.storage.is_bot(): log.warning(f"Users cannot send messages with Game media type. " - f"chat_id: {self.chat.id}, message_id: {self.message_id}") + f"chat_id: {self.chat.id}, message_id: {self.id}") elif self.empty: log.warning(f"Empty messages cannot be copied. ") elif self.text: @@ -3102,7 +3102,7 @@ class Message(Object, Update): client.delete_messages( chat_id=chat_id, - message_ids=message.message_id + message_ids=message.id ) Example: @@ -3125,7 +3125,7 @@ class Message(Object, Update): """ return await self._client.delete_messages( chat_id=self.chat.id, - message_ids=self.message_id, + message_ids=self.id, revoke=revoke ) @@ -3140,7 +3140,7 @@ class Message(Object, Update): client.request_callback_answer( chat_id=message.chat.id, - message_id=message.message_id, + message_id=message.id, callback_data=message.reply_markup[i][j].callback_data ) @@ -3235,7 +3235,7 @@ class Message(Object, Update): if button.callback_data: return await self._client.request_callback_answer( chat_id=self.chat.id, - message_id=self.message_id, + message_id=self.id, callback_data=button.callback_data, timeout=timeout ) @@ -3314,7 +3314,7 @@ class Message(Object, Update): return await self._client.retract_vote( chat_id=self.chat.id, - message_id=self.message_id + message_id=self.id ) async def download( @@ -3397,7 +3397,7 @@ class Message(Object, Update): client.vote_poll( chat_id=message.chat.id, - message_id=message.message_id, + message_id=message.id, option=1 ) @@ -3419,7 +3419,7 @@ class Message(Object, Update): return await self._client.vote_poll( chat_id=self.chat.id, - message_id=self.message_id, + message_id=self.id, options=option ) @@ -3457,7 +3457,7 @@ class Message(Object, Update): """ return await self._client.pin_chat_message( chat_id=self.chat.id, - message_id=self.message_id, + message_id=self.id, disable_notification=disable_notification, both_sides=both_sides ) @@ -3487,5 +3487,5 @@ class Message(Object, Update): """ return await self._client.unpin_chat_message( chat_id=self.chat.id, - message_id=self.message_id + message_id=self.id ) diff --git a/pyrogram/utils.py b/pyrogram/utils.py index 94a54946..60f6ca9d 100644 --- a/pyrogram/utils.py +++ b/pyrogram/utils.py @@ -115,10 +115,10 @@ async def parse_messages(client, messages: "raw.types.messages.Messages", replie ) for message in parsed_messages: - reply_id = messages_with_replies.get(message.message_id, None) + reply_id = messages_with_replies.get(message.id, None) for reply in reply_messages: - if reply.message_id == reply_id: + if reply.id == reply_id: message.reply_to_message = reply return types.List(parsed_messages) @@ -133,10 +133,10 @@ def parse_deleted_messages(client, update) -> List["types.Message"]: for message in messages: parsed_messages.append( types.Message( - message_id=message, + id=message, chat=types.Chat( id=get_channel_id(channel_id), - type="channel", + type=enums.ChatType.CHANNEL, client=client ) if channel_id is not None else None, client=client