fix nonetype

This commit is contained in:
Mylloon 2022-08-09 02:32:34 +02:00
parent 6eab4a41b3
commit f351e477e3
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

10
main.py
View file

@ -336,18 +336,26 @@ def start():
# Check if rules already exists # Check if rules already exists
old_rules = stream.get_rules().data old_rules = stream.get_rules().data
old_rules_values = []
if old_rules:
old_rules_values = [rule.value for rule in old_rules] old_rules_values = [rule.value for rule in old_rules]
need_changes = False
# Same amount of rules # Same amount of rules
if len(old_rules_values) == len(rules): if len(old_rules_values) == len(rules):
for rule in rules: for rule in rules:
# Check if Twitter doesn't know the rule and change rules if needed # Check if Twitter doesn't know the rule and change rules if needed
if rule not in old_rules_values: if rule not in old_rules_values:
need_changes = True
break
else:
need_changes = True
if need_changes:
# Clean old rules # Clean old rules
stream.delete_rules([rule.id for rule in old_rules]) stream.delete_rules([rule.id for rule in old_rules])
# Add new rules # Add new rules
stream.add_rules([StreamRule(rule) for rule in rules]) stream.add_rules([StreamRule(rule) for rule in rules])
break
# Apply the filter # Apply the filter
stream.filter(threaded=True, tweet_fields="author_id") stream.filter(threaded=True, tweet_fields="author_id")