diff --git a/bot.py b/bot.py index 2c69904..c5869bc 100755 --- a/bot.py +++ b/bot.py @@ -10,7 +10,8 @@ import config import auth # choose a random image -randomImage = config.picturePath + random.choice(os.listdir(config.picturePath)) +randomImageChoice = random.choice(os.listdir(config.picturePath)) +randomImage = config.picturePath + randomImageChoice # connect to the mastodon api mastodon = Mastodon( @@ -28,6 +29,9 @@ media = mastodon.media_post(randomImage, None, config.desc) # post image as status tootSent = mastodon.status_post(config.status, media_ids=media) +# clean up and make sure image not used again +os.rename(randomImage, config.usedPicturePath+randomImageChoice) + print('Sent!') print(tootSent['url']) diff --git a/config.py b/config.py index c2d23ca..dd78a0b 100644 --- a/config.py +++ b/config.py @@ -3,6 +3,7 @@ import random, status instance = 'https://tilde.zone/' picturePath = '/var/www/html/o/' +usedPicturePath = '/var/www/html/ou/' status = random.choice(status.statuses) desc = "A picture of the OwO Tower"