Skip to content

Commit

Permalink
Update julia-trancou.py
Browse files Browse the repository at this point in the history
bot now actually checks for drop out status, which was asked earlier in a direct message
  • Loading branch information
jbiers authored Nov 13, 2021
1 parent 31d7f5f commit 0e7c502
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions julia-trancou.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
ACCESS_KEY = environ['ACCESS_KEY']
ACCESS_SECRET = environ['ACCESS_SECRET']

# Set id for my personal account
PERSONAL_ID = environ['PERSONAL_ID']
dropped_out = False

# Define date for last post
file = open("last-post-day.txt", "r+")
last_post_day = int(file.read())
Expand Down Expand Up @@ -35,14 +39,21 @@
api = tweepy.API(auth)
now = datetime.today()

# Create messages object
messages = api.get_direct_messages()

# This function is the one to be called every day to post my twitter


def tweet_college_status():
# Only post tweet if last update was made the day before
if (now.day != last_post_day):
api.update_status("Julia não trancou a faculdade até o dia " +
str(now.day) + " de " + CALENDAR[now.month] + ".")
if dropped_out == False:
api.update_status("Julia não trancou a faculdade até o dia " +
str(now.day) + " de " + CALENDAR[now.month] + ".")

if dropped_out == True:
api.update_status("Julia trancou a faculdade.")

print("Tweeting status...")

Expand All @@ -54,6 +65,16 @@ def tweet_college_status():
print("Status was already updated today.")


tweet_college_status()
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
tweet_college_status()
break

tweet_college_status()
break

file.close()

0 comments on commit 0e7c502

Please sign in to comment.