get ids of users

This commit is contained in:
Mylloon 2022-08-06 00:24:24 +02:00
parent bd866f02cd
commit baee3bf44c
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 12 additions and 2 deletions

5
.gitignore vendored
View file

@ -1,2 +1,5 @@
.env .env
env/
bin/
lib/
pyvenv.cfg

View file

@ -63,7 +63,7 @@ class Listener(StreamListener):
self.api = api self.api = api
self.accounts = users self.accounts = users
self.forcelist = forcelist self.forcelist = forcelist
self.listOfFriendsID = getFriendsID(api, users) + forcelist self.listOfFriendsID = getFriendsID(api, users) + getIDs(api, forcelist)
def on_connect(self): def on_connect(self):
print(f"Scroll sur Twitter avec les abonnements de @{', @'.join(self.accounts)} comme timeline et ces comptes : @{', @'.join(self.forcelist)}...") print(f"Scroll sur Twitter avec les abonnements de @{', @'.join(self.accounts)} comme timeline et ces comptes : @{', @'.join(self.forcelist)}...")
@ -139,6 +139,13 @@ def getFriendsID(api, users: list) -> list:
liste.extend(api.friends_ids(user)) liste.extend(api.friends_ids(user))
return list(set(liste)) return list(set(liste))
def getIDs(api, users: list) -> list:
"""Get all the ID of users"""
liste = []
for user in users:
liste.append(api.get_user(user)._json["id"])
return list(set(liste))
def seniority(date: str) -> bool: def seniority(date: str) -> bool:
"""Return True only if the given string date is less than one day old.""" """Return True only if the given string date is less than one day old."""
datetimeObject = datetime.strptime(date, "%a %b %d %H:%M:%S +0000 %Y") # convert String format to datetime format datetimeObject = datetime.strptime(date, "%a %b %d %H:%M:%S +0000 %Y") # convert String format to datetime format