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
f1bbd262e7
@ -53,18 +53,28 @@ class twitter:
|
|||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
try:
|
try:
|
||||||
# Get hashtag list
|
# 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
|
# It's a blocklist and the hashtag is found
|
||||||
if self.credentials['is_blocklist'] and hashtag in self.credentials['hashtags']:
|
if self.credentials['is_blocklist'] and each['text'] in hashtags:
|
||||||
exit(0)
|
found_not_allowed_tag = True
|
||||||
|
break
|
||||||
|
|
||||||
# It is a list of allowed hashtags and the hashtag was not found
|
# It is a list of allowed hashtags and the hashtag was found
|
||||||
if not self.credentials['is_blocklist'] and hashtag not in self.credentials['hashtags']:
|
if not self.credentials['is_blocklist'] and each['text'] in hashtags:
|
||||||
exit(0)
|
found_not_allowed_tag = False
|
||||||
|
break
|
||||||
|
|
||||||
if self.credentials['omit_replies'] and r.json()[0]['in_reply_to_status_id']:
|
if self.credentials['omit_replies'] and r.json()[0]['in_reply_to_status_id']:
|
||||||
# Tweet is a reply
|
# Tweet is a reply
|
||||||
|
found_not_allowed_tag = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if found_not_allowed_tag:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user