Add fetchAllUsersFromThreads

Add a method to get all users involved in threads (given as a parameter)
This commit is contained in:
2FWAH
2018-06-01 23:27:34 +02:00
committed by GitHub
parent abe3357e67
commit 0767ef4902

View File

@@ -494,7 +494,29 @@ class Client(object):
else:
break
return Threads # from newest to oldest
def fetchAllUsersFromThreads(client, threads):
"""
Get all users involved in threads.
:param threads: models.Thread: List of threads to check for users
:return: :class:`models.User` objects
:rtype: list
:raises: FBchatException if request failed
"""
Users = []
for thread in threads:
if thread.type == ThreadType.USER:
if thread.uid not in [user.uid for user in Users]:
Users.append(thread)
elif thread.type == ThreadType.GROUP:
for userID in thread.participants:
if userID not in [user.uid for user in Users]:
Users.append(self.fetchUserInfo(userID)[userID])
else:
pass
return Users
def fetchAllUsers(self):
"""
Gets all users the client is currently chatting with