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

Rename Message.message_id to Message.id

This commit is contained in:
Dan 2022-04-24 11:56:06 +02:00
parent b697826b5a
commit 274650cda9
7 changed files with 61 additions and 61 deletions

View File

@ -93,7 +93,7 @@ class IterDialogs(Scaffold):
last = dialogs[-1] last = dialogs[-1]
offset_id = last.top_message.message_id offset_id = last.top_message.id
offset_date = last.top_message.date offset_date = last.top_message.date
offset_peer = await self.resolve_peer(last.chat.id) offset_peer = await self.resolve_peer(last.chat.id)

View File

@ -89,7 +89,7 @@ class IterHistory(Scaffold):
if not messages: if not messages:
return 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: for message in messages:
yield message yield message

View File

@ -102,7 +102,7 @@ class SearchGlobal(Scaffold):
offset_date = last.date offset_date = last.date
offset_peer = await self.resolve_peer(last.chat.id) offset_peer = await self.resolve_peer(last.chat.id)
offset_id = last.message_id offset_id = last.id
for message in messages: for message in messages:
yield message yield message

View File

@ -149,7 +149,7 @@ class SendMessage(Scaffold):
) )
return types.Message( return types.Message(
message_id=r.id, id=r.id,
chat=types.Chat( chat=types.Chat(
id=peer_id, id=peer_id,
type=enums.ChatType.PRIVATE, type=enums.ChatType.PRIVATE,

View File

@ -203,7 +203,7 @@ class CallbackQuery(Object, Update):
if self.inline_message_id is None: if self.inline_message_id is None:
return await self._client.edit_message_text( return await self._client.edit_message_text(
chat_id=self.message.chat.id, chat_id=self.message.chat.id,
message_id=self.message.message_id, message_id=self.message.id,
text=text, text=text,
parse_mode=parse_mode, parse_mode=parse_mode,
disable_web_page_preview=disable_web_page_preview, disable_web_page_preview=disable_web_page_preview,
@ -274,7 +274,7 @@ class CallbackQuery(Object, Update):
if self.inline_message_id is None: if self.inline_message_id is None:
return await self._client.edit_message_media( return await self._client.edit_message_media(
chat_id=self.message.chat.id, chat_id=self.message.chat.id,
message_id=self.message.message_id, message_id=self.message.id,
media=media, media=media,
reply_markup=reply_markup reply_markup=reply_markup
) )
@ -307,7 +307,7 @@ class CallbackQuery(Object, Update):
if self.inline_message_id is None: if self.inline_message_id is None:
return await self._client.edit_message_reply_markup( return await self._client.edit_message_reply_markup(
chat_id=self.message.chat.id, chat_id=self.message.chat.id,
message_id=self.message.message_id, message_id=self.message.id,
reply_markup=reply_markup reply_markup=reply_markup
) )
else: else:

View File

@ -60,7 +60,7 @@ class Message(Object, Update):
"""A message. """A message.
Parameters: Parameters:
message_id (``int``): id (``int``):
Unique message identifier inside this chat. Unique message identifier inside this chat.
from_user (:obj:`~pyrogram.types.User`, *optional*): from_user (:obj:`~pyrogram.types.User`, *optional*):
@ -302,7 +302,7 @@ class Message(Object, Update):
self, self,
*, *,
client: "pyrogram.Client" = None, client: "pyrogram.Client" = None,
message_id: int, id: int,
from_user: "types.User" = None, from_user: "types.User" = None,
sender_chat: "types.Chat" = None, sender_chat: "types.Chat" = None,
date: datetime = None, date: datetime = None,
@ -376,7 +376,7 @@ class Message(Object, Update):
): ):
super().__init__(client) super().__init__(client)
self.message_id = message_id self.id = id
self.from_user = from_user self.from_user = from_user
self.sender_chat = sender_chat self.sender_chat = sender_chat
self.date = date self.date = date
@ -453,7 +453,7 @@ class Message(Object, Update):
replies: int = 1 replies: int = 1
): ):
if isinstance(message, raw.types.MessageEmpty): 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) from_id = utils.get_raw_peer_id(message.from_id)
peer_id = utils.get_raw_peer_id(message.peer_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 sender_chat = types.Chat._parse(client, message, users, chats, is_chat=False) if not from_user else None
parsed_message = Message( parsed_message = Message(
message_id=message.id, id=message.id,
date=utils.timestamp_to_datetime(message.date), date=utils.timestamp_to_datetime(message.date),
chat=types.Chat._parse(client, message, users, chats, is_chat=True), chat=types.Chat._parse(client, message, users, chats, is_chat=True),
from_user=from_user, from_user=from_user,
@ -739,7 +739,7 @@ class Message(Object, Update):
for r in message.reactions.results] if message.reactions else None for r in message.reactions.results] if message.reactions else None
parsed_message = Message( parsed_message = Message(
message_id=message.id, id=message.id,
date=utils.timestamp_to_datetime(message.date), date=utils.timestamp_to_datetime(message.date),
chat=types.Chat._parse(client, message, users, chats, is_chat=True), chat=types.Chat._parse(client, message, users, chats, is_chat=True),
from_user=from_user, 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) self.chat.type in (enums.ChatType.GROUP, enums.ChatType.SUPERGROUP, enums.ChatType.CHANNEL)
and self.chat.username 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: 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"]: async def get_media_group(self) -> List["types.Message"]:
"""Bound method *get_media_group* of :obj:`~pyrogram.types.Message`. """Bound method *get_media_group* of :obj:`~pyrogram.types.Message`.
@ -836,7 +836,7 @@ class Message(Object, Update):
client.get_media_group( client.get_media_group(
chat_id=message.chat.id, chat_id=message.chat.id,
message_id=message.message_id message_id=message.id
) )
Example: Example:
@ -853,7 +853,7 @@ class Message(Object, Update):
return await self._client.get_media_group( return await self._client.get_media_group(
chat_id=self.chat.id, chat_id=self.chat.id,
message_id=self.message_id message_id=self.id
) )
async def reply_text( async def reply_text(
@ -880,7 +880,7 @@ class Message(Object, Update):
client.send_message( client.send_message(
chat_id=message.chat.id, chat_id=message.chat.id,
text="hello", text="hello",
reply_to_message_id=message.message_id reply_to_message_id=message.id
) )
Example: Example:
@ -934,7 +934,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_message(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -1071,7 +1071,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_animation(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -1210,7 +1210,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_audio(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -1302,7 +1302,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_cached_media(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -1425,7 +1425,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_contact(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -1561,7 +1561,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_document(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -1639,7 +1639,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_game(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -1703,7 +1703,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_inline_bot_result(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -1777,7 +1777,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_location(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -1840,7 +1840,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_media_group(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -1956,7 +1956,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_photo(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -2060,7 +2060,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_poll(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -2164,7 +2164,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_sticker(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -2259,7 +2259,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_venue(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -2404,7 +2404,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_video(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -2528,7 +2528,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_video_note(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -2648,7 +2648,7 @@ class Message(Object, Update):
quote = self.chat.type != "private" quote = self.chat.type != "private"
if reply_to_message_id is None and quote: 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( return await self._client.send_voice(
chat_id=self.chat.id, chat_id=self.chat.id,
@ -2682,7 +2682,7 @@ class Message(Object, Update):
client.edit_message_text( client.edit_message_text(
chat_id=message.chat.id, chat_id=message.chat.id,
message_id=message.message_id, message_id=message.id,
text="hello" text="hello"
) )
@ -2716,7 +2716,7 @@ class Message(Object, Update):
""" """
return await self._client.edit_message_text( return await self._client.edit_message_text(
chat_id=self.chat.id, chat_id=self.chat.id,
message_id=self.message_id, message_id=self.id,
text=text, text=text,
parse_mode=parse_mode, parse_mode=parse_mode,
entities=entities, entities=entities,
@ -2741,7 +2741,7 @@ class Message(Object, Update):
client.edit_message_caption( client.edit_message_caption(
chat_id=message.chat.id, chat_id=message.chat.id,
message_id=message.message_id, message_id=message.id,
caption="hello" caption="hello"
) )
@ -2772,7 +2772,7 @@ class Message(Object, Update):
""" """
return await self._client.edit_message_caption( return await self._client.edit_message_caption(
chat_id=self.chat.id, chat_id=self.chat.id,
message_id=self.message_id, message_id=self.id,
caption=caption, caption=caption,
parse_mode=parse_mode, parse_mode=parse_mode,
caption_entities=caption_entities, caption_entities=caption_entities,
@ -2792,7 +2792,7 @@ class Message(Object, Update):
client.edit_message_media( client.edit_message_media(
chat_id=message.chat.id, chat_id=message.chat.id,
message_id=message.message_id, message_id=message.id,
media=media media=media
) )
@ -2816,7 +2816,7 @@ class Message(Object, Update):
""" """
return await self._client.edit_message_media( return await self._client.edit_message_media(
chat_id=self.chat.id, chat_id=self.chat.id,
message_id=self.message_id, message_id=self.id,
media=media, media=media,
reply_markup=reply_markup reply_markup=reply_markup
) )
@ -2830,7 +2830,7 @@ class Message(Object, Update):
client.edit_message_reply_markup( client.edit_message_reply_markup(
chat_id=message.chat.id, chat_id=message.chat.id,
message_id=message.message_id, message_id=message.id,
reply_markup=inline_reply_markup reply_markup=inline_reply_markup
) )
@ -2852,7 +2852,7 @@ class Message(Object, Update):
""" """
return await self._client.edit_message_reply_markup( return await self._client.edit_message_reply_markup(
chat_id=self.chat.id, chat_id=self.chat.id,
message_id=self.message_id, message_id=self.id,
reply_markup=reply_markup reply_markup=reply_markup
) )
@ -2871,7 +2871,7 @@ class Message(Object, Update):
client.forward_messages( client.forward_messages(
chat_id=chat_id, chat_id=chat_id,
from_chat_id=message.chat.id, from_chat_id=message.chat.id,
message_ids=message.message_id message_ids=message.id
) )
Example: Example:
@ -2901,7 +2901,7 @@ class Message(Object, Update):
return await self._client.forward_messages( return await self._client.forward_messages(
chat_id=chat_id, chat_id=chat_id,
from_chat_id=self.chat.id, from_chat_id=self.chat.id,
message_ids=self.message_id, message_ids=self.id,
disable_notification=disable_notification, disable_notification=disable_notification,
schedule_date=schedule_date schedule_date=schedule_date
) )
@ -2932,7 +2932,7 @@ class Message(Object, Update):
client.copy_message( client.copy_message(
chat_id=chat_id, chat_id=chat_id,
from_chat_id=message.chat.id, from_chat_id=message.chat.id,
message_id=message.message_id message_id=message.id
) )
Example: Example:
@ -2985,10 +2985,10 @@ class Message(Object, Update):
""" """
if self.service: if self.service:
log.warning(f"Service messages cannot be copied. " 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(): elif self.game and not await self._client.storage.is_bot():
log.warning(f"Users cannot send messages with Game media type. " 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: elif self.empty:
log.warning(f"Empty messages cannot be copied. ") log.warning(f"Empty messages cannot be copied. ")
elif self.text: elif self.text:
@ -3102,7 +3102,7 @@ class Message(Object, Update):
client.delete_messages( client.delete_messages(
chat_id=chat_id, chat_id=chat_id,
message_ids=message.message_id message_ids=message.id
) )
Example: Example:
@ -3125,7 +3125,7 @@ class Message(Object, Update):
""" """
return await self._client.delete_messages( return await self._client.delete_messages(
chat_id=self.chat.id, chat_id=self.chat.id,
message_ids=self.message_id, message_ids=self.id,
revoke=revoke revoke=revoke
) )
@ -3140,7 +3140,7 @@ class Message(Object, Update):
client.request_callback_answer( client.request_callback_answer(
chat_id=message.chat.id, chat_id=message.chat.id,
message_id=message.message_id, message_id=message.id,
callback_data=message.reply_markup[i][j].callback_data callback_data=message.reply_markup[i][j].callback_data
) )
@ -3235,7 +3235,7 @@ class Message(Object, Update):
if button.callback_data: if button.callback_data:
return await self._client.request_callback_answer( return await self._client.request_callback_answer(
chat_id=self.chat.id, chat_id=self.chat.id,
message_id=self.message_id, message_id=self.id,
callback_data=button.callback_data, callback_data=button.callback_data,
timeout=timeout timeout=timeout
) )
@ -3314,7 +3314,7 @@ class Message(Object, Update):
return await self._client.retract_vote( return await self._client.retract_vote(
chat_id=self.chat.id, chat_id=self.chat.id,
message_id=self.message_id message_id=self.id
) )
async def download( async def download(
@ -3397,7 +3397,7 @@ class Message(Object, Update):
client.vote_poll( client.vote_poll(
chat_id=message.chat.id, chat_id=message.chat.id,
message_id=message.message_id, message_id=message.id,
option=1 option=1
) )
@ -3419,7 +3419,7 @@ class Message(Object, Update):
return await self._client.vote_poll( return await self._client.vote_poll(
chat_id=self.chat.id, chat_id=self.chat.id,
message_id=self.message_id, message_id=self.id,
options=option options=option
) )
@ -3457,7 +3457,7 @@ class Message(Object, Update):
""" """
return await self._client.pin_chat_message( return await self._client.pin_chat_message(
chat_id=self.chat.id, chat_id=self.chat.id,
message_id=self.message_id, message_id=self.id,
disable_notification=disable_notification, disable_notification=disable_notification,
both_sides=both_sides both_sides=both_sides
) )
@ -3487,5 +3487,5 @@ class Message(Object, Update):
""" """
return await self._client.unpin_chat_message( return await self._client.unpin_chat_message(
chat_id=self.chat.id, chat_id=self.chat.id,
message_id=self.message_id message_id=self.id
) )

View File

@ -115,10 +115,10 @@ async def parse_messages(client, messages: "raw.types.messages.Messages", replie
) )
for message in parsed_messages: 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: for reply in reply_messages:
if reply.message_id == reply_id: if reply.id == reply_id:
message.reply_to_message = reply message.reply_to_message = reply
return types.List(parsed_messages) return types.List(parsed_messages)
@ -133,10 +133,10 @@ def parse_deleted_messages(client, update) -> List["types.Message"]:
for message in messages: for message in messages:
parsed_messages.append( parsed_messages.append(
types.Message( types.Message(
message_id=message, id=message,
chat=types.Chat( chat=types.Chat(
id=get_channel_id(channel_id), id=get_channel_id(channel_id),
type="channel", type=enums.ChatType.CHANNEL,
client=client client=client
) if channel_id is not None else None, ) if channel_id is not None else None,
client=client client=client