From 0271c1c6a04959ab645a3116ce853d71734760b7 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 4 Aug 2021 14:50:09 +0200 Subject: [PATCH] opti if order --- main.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/main.py b/main.py index d728300..e3cd10b 100644 --- a/main.py +++ b/main.py @@ -31,21 +31,21 @@ class Listener(StreamListener): def on_status(self, status): """Answer to tweets.""" - if seniority(status._json["created_at"]): - tweetText = sub(r'https?:\/\/\S+| +?\?|\?| +?\!| ?\!|-|~', '', status._json["text"]) - if status._json["user"]["id"] in self.listOfFriendsID: + if status._json["user"]["id"] in self.listOfFriendsID: + if seniority(status._json["created_at"]): + tweetText = sub(r'https?:\/\/\S+| +?\?|\?| +?\!| ?\!|-|~', '', status._json["text"]) lastWord = tweetText.split()[-1:][0].lower() if lastWord in universalBase: + if lastWord in quoiBase: + answer = feur + elif lastWord in ouiBase: + answer = stiti + elif lastWord in nonBase: + answer = bril + else: # temporary + print(f"{errorMessage} I didn't know how to answer.") + return try: - if lastWord in quoiBase: - answer = feur - elif lastWord in ouiBase: - answer = stiti - elif lastWord in nonBase: - answer = bril - else: - print(f"{errorMessage} I didn't know how to answer.") - return self.api.update_status(status = choice(answer), in_reply_to_status_id = status._json["id"], auto_populate_reply_metadata = True) print(f"{status._json['user']['screen_name']} s'est fait {answer[0]} !") except Exception as error: