From 30615db0637756c3dabf39fd99fd861fa2a019e0 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 8 Aug 2022 09:48:25 +0200 Subject: [PATCH] clean rules first --- main.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 2413683..748c2c1 100644 --- a/main.py +++ b/main.py @@ -331,12 +331,13 @@ def start(): stream = Listener(keys["BEARER_TOKEN"], client) # Clean rules - for rule in stream.get_rules().data: - stream.delete_rules(rule.id) + old_rules = stream.get_rules() + if (old_rules.data): + stream.delete_rules([rule for rule in old_rules.data]) # Add new rules - for rule in create_rules(tracked_users): - stream.add_rules(StreamRule(rule)) + stream.add_rules([StreamRule(rule) + for rule in create_rules(tracked_users)]) stream.filter(threaded=True, tweet_fields=['author_id'])