Compare commits
No commits in common. "c0b5c168a79dd3d829d5dcdab25e74c7f44384f3" and "0874d5211d25923fe0c76cec14a2c74f8f564e0e" have entirely different histories.
c0b5c168a7
...
0874d5211d
2 changed files with 18 additions and 24 deletions
|
@ -16,7 +16,7 @@ N'hésitez pas à ouvrir un ticket ou faire une merge-request pour contribuer au
|
||||||
|
|
||||||
## Lancer le Bot
|
## Lancer le Bot
|
||||||
|
|
||||||
Donner la permission au minimum `Read and Write` au bot dans `Settings` puis `App permissions`.
|
Donner la permission `Read and Write` (ou `Read + Write + Direct Messages` mais aucun DM n'est envoyé) au bot dans `Settings` puis `App permissions`.
|
||||||
|
|
||||||
Les codes fourni par l'API de Twitter sont généralements disponible dans la page `Keys and tokens`.
|
Les codes fourni par l'API de Twitter sont généralements disponible dans la page `Keys and tokens`.
|
||||||
|
|
||||||
|
|
40
main.py
40
main.py
|
@ -85,7 +85,7 @@ class Listener(StreamingClient):
|
||||||
"users": users,
|
"users": users,
|
||||||
"forcelist": forcelist
|
"forcelist": forcelist
|
||||||
}
|
}
|
||||||
self.victim_list = getFriends(client, users) + getIDs(client, forcelist)
|
self.listOfFriendsID = getFriendsID(client, users) + getIDs(client, forcelist)
|
||||||
|
|
||||||
def on_connect(self):
|
def on_connect(self):
|
||||||
if self.accounts['forcelist'] == []:
|
if self.accounts['forcelist'] == []:
|
||||||
|
@ -101,11 +101,9 @@ class Listener(StreamingClient):
|
||||||
print(f"Raison : {notice['reason']}")
|
print(f"Raison : {notice['reason']}")
|
||||||
|
|
||||||
def on_status(self, status):
|
def on_status(self, status):
|
||||||
print(status)
|
|
||||||
exit(0)
|
|
||||||
json = status._json
|
json = status._json
|
||||||
# Verify the author of the tweet
|
# Verify the author of the tweet
|
||||||
if json["user"]["id"] in self.victim_list and json["user"]["screen_name"] not in keys["WHITELIST"]:
|
if json["user"]["id"] in self.listOfFriendsID and json["user"]["screen_name"] not in keys["WHITELIST"]:
|
||||||
# Verify the age of the tweet
|
# Verify the age of the tweet
|
||||||
if seniority(json["created_at"]):
|
if seniority(json["created_at"]):
|
||||||
# Verify if the tweet isn't a retweet
|
# Verify if the tweet isn't a retweet
|
||||||
|
@ -200,22 +198,23 @@ def repeater(word: str) -> str:
|
||||||
# Random format from the base answer
|
# Random format from the base answer
|
||||||
return createBaseAnswers(word)
|
return createBaseAnswers(word)
|
||||||
|
|
||||||
def getFriends(client: Client, users: list[str]) -> list:
|
def getFriendsID(client: Client, users: list[str]) -> list:
|
||||||
"""Get all friends of choosen users"""
|
"""Get all friends of choosen users"""
|
||||||
friends_list = []
|
liste = []
|
||||||
# Get IDs of the user's friends
|
# Get IDs of the user's friends
|
||||||
for user in users:
|
for user in users:
|
||||||
user_id = client.get_user(username=user, user_auth=True).data.id
|
# TODO: Update Twitter API V2
|
||||||
friends_list.extend(client.get_users_following(id=user_id, user_auth=True))
|
liste.extend(client.get_friend_ids(screen_name=user))
|
||||||
return friends_list[0]
|
return list(set(liste))
|
||||||
|
|
||||||
def getIDs(client: Client, users: list[str]) -> list:
|
def getIDs(client: Client, users: list[str]) -> list:
|
||||||
"""Get all the ID of users"""
|
"""Get all the ID of users"""
|
||||||
users_list = []
|
liste = []
|
||||||
# Get IDs of the users
|
# Get IDs of the users
|
||||||
for user in users:
|
for user in users:
|
||||||
users_list.append(client.get_user(username=user, user_auth=True).data)
|
# TODO: Update Twitter API V2
|
||||||
return users_list
|
liste.append(client.get_user(screen_name=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"""
|
||||||
|
@ -326,17 +325,12 @@ def start():
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
"""
|
"""
|
||||||
TOKEN is the Access Token available in the Authentication Tokens section under the Access Token and Secret sub-heading
|
TOKEN is the Access Token available in the Authentication Tokens section under Access Token and Secret sub-heading.
|
||||||
TOKEN_SECRET is the Access Token Secret available in the Authentication Tokens section under the Access Token and Secret sub-heading
|
TOKEN_SECRET is the Access Token Secret available in the Authentication Tokens section under Access Token and Secret sub-heading.
|
||||||
CONSUMER_KEY is the API Key available in the Consumer Keys section under the API Key and Secret sub-heading
|
CONSUMER_KEY is the API Key available in the Consumer Keys section.
|
||||||
CONSUMER_SECRET is the API Secret Key available in the Consumer Keys section under the API Key and Secret sub-heading
|
CONSUMER_SECRET is the API Secret Key available in the Consumer Keys section.
|
||||||
BEARER_TOKEN is the Bearer Token available in the Authentication Tokens section under the Bearer Token sub-heading
|
|
||||||
--
|
--
|
||||||
PSEUDOS is a list of account you want to listen, all of his·er following (guys followed by PSEUDO) will be sniped
|
PSEUDO is the PSEUDO of the account you want to listen to snipe.
|
||||||
WHITELSIT is a list of account who are protected from the bot
|
|
||||||
FORCELIST is a list of account who are targeted by the bot, if user is in the whitelist, he·r will be ignored
|
|
||||||
---
|
|
||||||
VERBOSE enable some debugs log
|
|
||||||
"""
|
"""
|
||||||
# Error message
|
# Error message
|
||||||
errorMessage = "Une erreur survient !"
|
errorMessage = "Une erreur survient !"
|
||||||
|
@ -513,7 +507,7 @@ if __name__ == "__main__":
|
||||||
triggerWords = generateWords(universalBase)
|
triggerWords = generateWords(universalBase)
|
||||||
|
|
||||||
# Loading environment variables
|
# Loading environment variables
|
||||||
keys = load(["TOKEN", "TOKEN_SECRET", "CONSUMER_KEY", "CONSUMER_SECRET", "BEARER_TOKEN", "PSEUDOS", "VERBOSE", "WHITELIST", "FORCELIST"])
|
keys = load(["TOKEN", "TOKEN_SECRET", "CONSUMER_KEY", "CONSUMER_SECRET", "PSEUDOS", "VERBOSE", "WHITELIST", "FORCELIST", "BEARER_TOKEN"])
|
||||||
|
|
||||||
# Start the bot
|
# Start the bot
|
||||||
start()
|
start()
|
||||||
|
|
Reference in a new issue