2019-10-05 23:25:52 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import tweepy
|
|
|
|
from randstrip import createStrip
|
|
|
|
import os
|
|
|
|
|
|
|
|
fileDir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
fileDir = fileDir +"/"
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
status = createStrip("twitter.png")
|
|
|
|
if status == 0:
|
|
|
|
with open(fileDir+"twitter_token") as f:
|
|
|
|
tokens = f.readlines()
|
|
|
|
tokens = [x.strip() for x in tokens]
|
|
|
|
auth = tweepy.OAuthHandler(tokens[0],tokens[1])
|
|
|
|
auth.set_access_token(tokens[2],tokens[3])
|
|
|
|
api = tweepy.API(auth)
|
2020-03-25 15:11:26 +01:00
|
|
|
published = False
|
|
|
|
for i in range(0,100):
|
|
|
|
try:
|
|
|
|
api.verify_credentials()
|
|
|
|
api.update_with_media(fileDir+"twitter.png","Generatore automatico di strip. Striscia di oggi.")
|
|
|
|
published = True
|
|
|
|
except:
|
|
|
|
continue
|
|
|
|
break
|
|
|
|
if not(published):
|
2019-10-05 23:25:52 +02:00
|
|
|
print("Auth error")
|
|
|
|
else:
|
|
|
|
print("Error creating image\n")
|
|
|
|
print(status)
|