twitter: Add support for phrase.

Twitter supports phrase search by quoting terms such as "Zulip API".

If we use the feature, the current twitter-bot can't detect used
search phrase. We can detect used search phrase with this change.
This commit is contained in:
Sutou Kouhei 2019-12-18 10:57:01 +09:00 committed by Tim Abbott
parent 957b5e7ad8
commit 843b21769a

View file

@ -243,6 +243,10 @@ for status in statuses[::-1][:opts.limit_tweets]:
if opts.search_terms:
search_term_used = None
for term in opts.search_terms.split(","):
# Remove quotes from phrase:
# "Zulip API" -> Zulip API
if term.startswith('"') and term.endswith('"'):
term = term[1:-1]
if any(term.lower() in text for text in text_to_check):
search_term_used = term
break