Skip to content
This repository has been archived by the owner on Jun 3, 2023. It is now read-only.

Added POTUS twitter account and filters for messages with '-DJT' #27

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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"
Expand Down Expand Up @@ -57,7 +58,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():
Expand Down Expand Up @@ -244,6 +245,15 @@ def handle_data(self, logs, data):
logs.debug("Skipping tweet from user: %s (%s)" %
(screen_name, user_id_str))
return
# Only look at POTUS tweets from POTUS, then check that tweet is signed -DJT
if user_id_str != POTUS_USER_ID:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are gonna need to add this to the original checker, because right now it won't even reach this part if it isnt by @RealDonaldTrump

logs.debug("Skipping tweet from user: %s (%s)" %
(screen_name, user_id_str))
return
elif '-DJT' not in tweet:
logs.debug("Tweet not signed -DJT: %s" %
(tweet))
return

logs.info("Examining tweet: %s" % tweet)

Expand Down