Update 06/12/2020
* Added new configuration options, please update your twitter.json after updating! Please see ./etc/twitter.json for changes. * The hashtag list can now act as block list or include list, depending on `is_blocklist` * Replies can now be ignored by setting `omit_replies` to true. * Fixed bug where only one hashtag was processed
This commit is contained in:
parent
b252f8855b
commit
d17652b352
@ -53,18 +53,28 @@ class twitter:
|
||||
r.raise_for_status()
|
||||
try:
|
||||
# Get hashtag list
|
||||
hashtag = r.json()[0]['entities']['hashtags'][0]['text']
|
||||
tweet_tags = r.json()[0]['entities']['hashtags']
|
||||
hashtags = self.credentials['hashtags']
|
||||
found_not_allowed_tag = False
|
||||
|
||||
for each in tweet_tags:
|
||||
# print(each)
|
||||
# It's a blocklist and the hashtag is found
|
||||
if self.credentials['is_blocklist'] and hashtag in self.credentials['hashtags']:
|
||||
exit(0)
|
||||
if self.credentials['is_blocklist'] and each['text'] in hashtags:
|
||||
found_not_allowed_tag = True
|
||||
break
|
||||
|
||||
# It is a list of allowed hashtags and the hashtag was not found
|
||||
if not self.credentials['is_blocklist'] and hashtag not in self.credentials['hashtags']:
|
||||
exit(0)
|
||||
# It is a list of allowed hashtags and the hashtag was found
|
||||
if not self.credentials['is_blocklist'] and each['text'] in hashtags:
|
||||
found_not_allowed_tag = False
|
||||
break
|
||||
|
||||
if self.credentials['omit_replies'] and r.json()[0]['in_reply_to_status_id']:
|
||||
# Tweet is a reply
|
||||
found_not_allowed_tag = True
|
||||
break
|
||||
|
||||
if found_not_allowed_tag:
|
||||
exit(0)
|
||||
|
||||
except IndexError:
|
||||
|
Loading…
x
Reference in New Issue
Block a user