diff --git a/twitter.py b/twitter.py index fb2dc49..3df58fd 100644 --- a/twitter.py +++ b/twitter.py @@ -25,6 +25,7 @@ # The user ID of @realDonaldTrump. TRUMP_USER_ID = "25073877" +POTUS_USER_ID = "822215679726100480" # The URL pattern for links to tweets. TWEET_URL = "https://twitter.com/%s/status/%s" @@ -58,7 +59,7 @@ def start_streaming(self, callback): twitter_stream = Stream(self.twitter_auth, self.twitter_listener) self.logs.debug("Starting stream.") - twitter_stream.filter(follow=[TRUMP_USER_ID]) + twitter_stream.filter(follow=[TRUMP_USER_ID,POTUS_USER_ID]) # If we got here because of an API error, raise it. if self.twitter_listener.get_error_status(): @@ -260,12 +261,16 @@ def handle_data(self, logs, data): logs.error("Malformed tweet: %s" % tweet) return - # We're only interested in tweets from Mr. Trump himself, so skip the - # rest. - if user_id_str != TRUMP_USER_ID: + # We're only interested in tweets from Mr. Trump himself + # or from the POTUS account so skip the rest. + if user_id_str != TRUMP_USER_ID and user_id_str != POTUS_USER_ID: logs.debug("Skipping tweet from user: %s (%s)" % (screen_name, user_id_str)) return + # Also skip if tweet is from POTUS but not signed -DJT + if user_id_str == POTUS_USER_ID and '-DJT' not in tweet: + logs.debug("Skipping POTUS tweet because not signed -DJT") + return logs.info("Examining tweet: %s" % tweet)