1717# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818
1919import logging
20- from typing import Union , List
20+ from typing import Union , List , Iterable
2121
2222import pyrogram
2323from pyrogram import raw
@@ -34,8 +34,8 @@ class GetMessages:
3434 async def get_messages (
3535 self : "pyrogram.Client" ,
3636 chat_id : Union [int , str ],
37- message_ids : Union [int , List [int ]] = None ,
38- reply_to_message_ids : Union [int , List [int ]] = None ,
37+ message_ids : Union [int , Iterable [int ]] = None ,
38+ reply_to_message_ids : Union [int , Iterable [int ]] = None ,
3939 replies : int = 1
4040 ) -> Union ["types.Message" , List ["types.Message" ]]:
4141 """Get one or more messages from a chat by using message identifiers.
@@ -48,12 +48,12 @@ async def get_messages(
4848 For your personal cloud (Saved Messages) you can simply use "me" or "self".
4949 For a contact that exists in your Telegram address book you can use his phone number (str).
5050
51- message_ids (``int`` | List of ``int``, *optional*):
52- Pass a single message identifier or a list of message ids (as integers) to get the content of the
51+ message_ids (``int`` | Iterable of ``int``, *optional*):
52+ Pass a single message identifier or an iterable of message ids (as integers) to get the content of the
5353 message themselves.
5454
55- reply_to_message_ids (``int`` | List of ``int``, *optional*):
56- Pass a single message identifier or a list of message ids (as integers) to get the content of
55+ reply_to_message_ids (``int`` | Iterable of ``int``, *optional*):
56+ Pass a single message identifier or an iterable of message ids (as integers) to get the content of
5757 the previous message you replied to using this message.
5858 If *message_ids* is set, this argument will be ignored.
5959
@@ -98,10 +98,8 @@ async def get_messages(
9898
9999 peer = await self .resolve_peer (chat_id )
100100
101- is_list = isinstance (ids , list )
102- if not is_list :
103- ids = [ids ]
104-
101+ is_iterable = not isinstance (ids , int )
102+ ids = list (ids ) if is_iterable else [ids ]
105103 ids = [ids_type (id = i ) for i in ids ]
106104
107105 if replies < 0 :
@@ -116,4 +114,4 @@ async def get_messages(
116114
117115 messages = await utils .parse_messages (self , r , replies = replies )
118116
119- return messages if is_list else messages [0 ] if messages else None
117+ return messages if is_iterable else messages [0 ] if messages else None
0 commit comments