clean rules first

This commit is contained in:
Mylloon 2022-08-08 09:48:25 +02:00
parent 1eb5f84cc0
commit 30615db063
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -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'])