So, the function I have written involves saving a string to a text file at the end of each execution, and then calling that string in the next. It works fine locally, but not on Lambda. From what I can find, it looks like Lambda only supports writing to files in a /tmp folder, but it would only last for one execution, which doesn't work for me. How do I go about this?
Here is the relevant code, it's part of a tweepy bot.
def reply():
with open('lastid.txt', 'r+') as mf:
last = mf.readline()
response = client.get_users_mentions(user_id, since_id=last)
for tweet in response.data:
text = tweet.text
id = tweet.id
if any(x in text.lower() for x in strings):
client.create_tweet(in_reply_to_tweet_id=id, text=greet)
else:
client.create_tweet(in_reply_to_tweet_id=id, text=reply)
mf.write(str(tweet.id))
Thank you very much for any help! Maybe the answer is obvious but honestly my brain is a little fried at the moment.
lastvariable.