This is a twitter image bot that is called on every two hours to post a picture from a folder, the files are numbered consecutively and the current number is stored in a text file so it can stay constant between the runs. The image file types vary between .jpg and .gif and i dont know how to account for this in the picture() function of my code.
import os
from twython import Twython
from twython import TwythonStreamer
APP_KEY = ''
APP_SECRET = ''
OAUTH_TOKEN = ''
OAUTH_TOKEN_SECRET = ''
f = open('pictures.txt', 'r+')
z = f.read()
def picture():
picture = open('/0/' + 'picture' + str(z))
f.write(str(z)+'\n')
global z
z += 1
promote(picture)
f.write(z)
f.close
def promote(photo):
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
twitter.update_status_with_media(status='', media=photo)
picture()