From 59ab1591d2731d519d7d5273fc4d1a823d17ec2c Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 30 Apr 2018 14:22:13 +0200 Subject: [PATCH] Make get_users accept iterables --- pyrogram/client/client.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 312db23a..208b84ca 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -3533,14 +3533,15 @@ class Client: ) ) - def get_users(self, user_ids: list or int or str): + def get_users(self, user_ids): """Use this method to get information about a user. You can retrieve up to 200 users at once. Args: - user_ids (``list`` | ``int`` | ``str``): + user_ids (``iterable``): A list of User identifiers (id or username) or a single user id/username. For a contact that exists in your Telegram address book you can use his phone number (str). + Iterators and Generators are also accepted. Returns: On success and in case *user_ids* was a list, the returned value will be a list of the requested @@ -3550,8 +3551,8 @@ class Client: Raises: :class:`Error ` """ - is_list = isinstance(user_ids, list) - user_ids = user_ids if is_list else [user_ids] + is_iterable = not isinstance(user_ids, (int, str)) + user_ids = list(user_ids) if is_iterable else [user_ids] user_ids = [self.resolve_peer(i) for i in user_ids] r = self.send( @@ -3565,7 +3566,7 @@ class Client: for i in r: users.append(utils.parse_user(i)) - return users if is_list else users[0] + return users if is_iterable else users[0] def get_messages(self, chat_id: int or str,