Skip to content

Commit

Permalink
added send message script
Browse files Browse the repository at this point in the history
sends a message to my personal account asking whether I've dropped out or not
  • Loading branch information
jbiers authored Nov 13, 2021
1 parent a361b58 commit 31d7f5f
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions send_message.py
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?")

0 comments on commit 31d7f5f

Please sign in to comment.