Compare commits

..

2 commits

Author SHA1 Message Date
68144b56ca
fr tweets 2022-08-09 02:03:02 +02:00
a1effc03c7
reorder following twitter website 2022-08-09 00:35:14 +02:00
3 changed files with 14 additions and 15 deletions

View file

@ -1,6 +1,6 @@
TOKEN=
TOKEN_SECRET=
CONSUMER_KEY= CONSUMER_KEY=
CONSUMER_SECRET= CONSUMER_SECRET=
BEARER_TOKEN= BEARER_TOKEN=
TOKEN=
TOKEN_SECRET=
PSEUDO= PSEUDO=

View file

@ -39,11 +39,11 @@ docker build https://git.kennel.ml/Anri/feurBot.git#main --tag feurbot:main && \
docker run -d \ docker run -d \
--name="feurBot" \ --name="feurBot" \
feurbot:main \ feurbot:main \
--TOKEN="" \
--TOKEN_SECRET="" \
--CONSUMER_KEY="" \ --CONSUMER_KEY="" \
--CONSUMER_SECRET="" \ --CONSUMER_SECRET="" \
--BEARER_TOKEN="" \ --BEARER_TOKEN="" \
--TOKEN="" \
--TOKEN_SECRET="" \
--PSEUDOS="" --PSEUDOS=""
``` ```
Ou avec un `docker-compose.yml` : Ou avec un `docker-compose.yml` :
@ -54,11 +54,11 @@ services:
build: https://git.kennel.ml/Anri/feurBot.git#main build: https://git.kennel.ml/Anri/feurBot.git#main
container_name: feurBot container_name: feurBot
environment: environment:
- TOKEN=
- TOKEN_SECRET=
- CONSUMER_KEY= - CONSUMER_KEY=
- CONSUMER_SECRET= - CONSUMER_SECRET=
- BEARER_TOKEN= - BEARER_TOKEN=
- TOKEN=
- TOKEN_SECRET=
- PSEUDOS= - PSEUDOS=
restart: unless-stopped restart: unless-stopped
``` ```

17
main.py
View file

@ -1,5 +1,4 @@
from datetime import datetime from datetime import datetime
from json import loads
from os import environ from os import environ
from random import choice from random import choice
from re import findall, sub from re import findall, sub
@ -184,7 +183,8 @@ class Listener(StreamingClient):
if keys["VERBOSE"]: if keys["VERBOSE"]:
print("En attente de reconnexion...") print("En attente de reconnexion...")
case _: case _:
print("\n") # newline
print("")
return False return False
@ -194,7 +194,7 @@ def repeater(word: str) -> str:
# Explanation: Trigger word for the repeater is "di" and sometimes it is # Explanation: Trigger word for the repeater is "di" and sometimes it is
# "dis", sometimes its "dit", that's why we need to remove this 2 letters # "dis", sometimes its "dit", that's why we need to remove this 2 letters
# from the final answer # from the final answer
if word[0] == 's' or word[0] == 't': if word[0] == "s" or word[0] == "t":
word = word[1:] word = word[1:]
# Random format from the base answer # Random format from the base answer
@ -249,26 +249,25 @@ def createClient(consumer_key, consumer_secret, access_token, access_token_secre
if keys["VERBOSE"]: if keys["VERBOSE"]:
try: try:
client.get_me().data.username
print( print(
f"Authentification réussie en tant que @{client.get_me().data.username}.\n") f"Authentification réussie en tant que @{client.get_me().data.username}.\n")
# Compte ignorés # Compte ignorés
if keys['WHITELIST'] == []: if keys["WHITELIST"] == []:
whitelist = "Aucun" whitelist = "Aucun"
else: else:
whitelist = f"@{', @'.join(keys['WHITELIST'])}" whitelist = f"@{', @'.join(keys['WHITELIST'])}"
print(f"Liste des comptes ignorés : {whitelist}.") print(f"Liste des comptes ignorés : {whitelist}.")
# Compte forcés # Compte forcés
if keys['FORCELIST'] == []: if keys["FORCELIST"] == []:
forcelist = "Aucun" forcelist = "Aucun"
else: else:
forcelist = f"@{', @'.join(keys['FORCELIST'])}" forcelist = f"@{', @'.join(keys['FORCELIST'])}"
print(f"Liste des comptes forcés : {forcelist}.") print(f"Liste des comptes forcés : {forcelist}.")
# Compte aux following suivis # Compte aux following suivis
if keys['PSEUDOS'] == []: if keys["PSEUDOS"] == []:
pseudos = "Aucun" pseudos = "Aucun"
else: else:
pseudos = f"@{', @'.join(keys['PSEUDOS'])}" pseudos = f"@{', @'.join(keys['PSEUDOS'])}"
@ -289,7 +288,7 @@ def create_rules(tracked_users: list[str]) -> list[str]:
rules = [] rules = []
# Repeating rules # Repeating rules
repeat = "-is:retweet (" repeat = "-is:retweet lang:fr ("
# Buffer # Buffer
buffer = repeat buffer = repeat
@ -340,7 +339,7 @@ def start():
# Add new rules # Add new rules
stream.add_rules([StreamRule(rule) stream.add_rules([StreamRule(rule)
for rule in create_rules(tracked_users)]) for rule in create_rules(tracked_users)])
stream.filter(threaded=True, tweet_fields=['author_id']) stream.filter(threaded=True, tweet_fields="author_id")
if __name__ == "__main__": if __name__ == "__main__":