add some word detection

This commit is contained in:
Mylloon 2021-08-04 13:18:58 +02:00
parent 4384cf4ed1
commit c63e67814f

View file

@ -30,8 +30,8 @@ class Listener(StreamListener):
def on_status(self, status): def on_status(self, status):
"""Answer to tweets.""" """Answer to tweets."""
if seniority(status._json["created_at"]): if seniority(status._json["created_at"]):
tweetText = sub(r'https?:\/\/\S+| +?\?|\?| +?\!| ?\!', '', status._json["text"]) tweetText = sub(r'https?:\/\/\S+| +?\?|\?| +?\!| ?\!|-|~', '', status._json["text"])
if tweetText.endswith(tuple(quoi)): if tweetText.endswith(tuple(triggerWords)):
if status._json["user"]["id"] in self.listOfFriendsID: if status._json["user"]["id"] in self.listOfFriendsID:
try: try:
self.api.update_status(status = choice(feur), in_reply_to_status_id = status._json["id"], auto_populate_reply_metadata = True) self.api.update_status(status = choice(feur), in_reply_to_status_id = status._json["id"], auto_populate_reply_metadata = True)
@ -83,7 +83,7 @@ def main(accessToken: str, accessTokenSecret: str, consumerKey: str, consumerSec
stream = Stream(auth = api.auth, listener = listener) stream = Stream(auth = api.auth, listener = listener)
print(f"Scroll sur Twitter avec les abonnements de @{', @'.join(users)}...") print(f"Scroll sur Twitter avec les abonnements de @{', @'.join(users)}...")
stream.filter(track = quoi, languages = ["fr"], is_async = True) stream.filter(track = triggerWords, languages = ["fr"], is_async = True)
if __name__ == '__main__': if __name__ == '__main__':
""" """
@ -94,7 +94,8 @@ if __name__ == '__main__':
-- --
PSEUDO is the PSEUDO of the account you want to listen to snipe. PSEUDO is the PSEUDO of the account you want to listen to snipe.
""" """
quoi = permute(["quoi", "koi"]) quoiBase = ["quoi", "koi"]
triggerWords = permute(quoiBase)
feur = ["feur", "(feur)", "FEUR", "feur lol", "https://twitter.com/shukuzi62/status/1422611919538724868/video/1"] feur = ["feur", "(feur)", "FEUR", "feur lol", "https://twitter.com/shukuzi62/status/1422611919538724868/video/1"]
keys = load(["TOKEN", "TOKEN_SECRET", "CONSUMER_KEY", "CONSUMER_SECRET", "PSEUDOS"]) keys = load(["TOKEN", "TOKEN_SECRET", "CONSUMER_KEY", "CONSUMER_SECRET", "PSEUDOS"])
main(keys["TOKEN"], keys["TOKEN_SECRET"], keys["CONSUMER_KEY"], keys["CONSUMER_SECRET"], keys["PSEUDOS"]) main(keys["TOKEN"], keys["TOKEN_SECRET"], keys["CONSUMER_KEY"], keys["CONSUMER_SECRET"], keys["PSEUDOS"])