-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sends a message to my personal account asking whether I've dropped out or not
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import tweepy | ||
from os import environ | ||
|
||
# Define API keys | ||
CONSUMER_KEY = environ['CONSUMER_KEY'] | ||
CONSUMER_SECRET = environ['CONSUMER_SECRET'] | ||
ACCESS_KEY = environ['ACCESS_KEY'] | ||
ACCESS_SECRET = environ['ACCESS_SECRET'] | ||
|
||
PERSONAL_ID = environ['PERSONAL_ID'] | ||
dropped_out = False | ||
|
||
# Authenticate to Twitter using the defined constants | ||
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) | ||
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) | ||
|
||
# Set API object | ||
api = tweepy.API(auth) | ||
|
||
|
||
# Create messages object | ||
messages = api.get_direct_messages() | ||
|
||
for message in messages: | ||
|
||
# Check if message was sent by my personal account | ||
if message.message_create['sender_id'] == PERSONAL_ID: | ||
|
||
# Check if the answer "yes" was given from my personal account | ||
if message.message_create['message_data']['text'] == "yes" or message.message_create['message_data']['text'] == "y": | ||
dropped_out = True | ||
print("Dropped out.") | ||
break | ||
|
||
break | ||
|
||
if (dropped_out != True): | ||
api.send_direct_message(PERSONAL_ID, "Did you drop out?") |