From 843b21769a5dbee9614d0977658a23b7dd66ed1b Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 18 Dec 2019 10:57:01 +0900 Subject: [PATCH] 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. --- zulip/integrations/twitter/twitter-bot | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zulip/integrations/twitter/twitter-bot b/zulip/integrations/twitter/twitter-bot index 568881e..6d2d775 100755 --- a/zulip/integrations/twitter/twitter-bot +++ b/zulip/integrations/twitter/twitter-bot @@ -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