forked from oloturia/fumcaso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter_main.py
executable file
·39 lines (36 loc) · 993 Bytes
/
twitter_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python3
import tweepy
from randstrip import createStrip,readConfig
import os
import sys
fileDir = os.path.dirname(os.path.abspath(__file__))
fileDir = fileDir +"/"
if __name__ == "__main__":
if len(sys.argv) == 2:
altProfile = [sys.argv[1]]
else:
altProfile = False
config = readConfig(platform="twitter",profile=altProfile)
status = createStrip(config)
if status == 0:
with open(config["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)
published = False
for i in range(0,100):
try:
api.verify_credentials()
api.update_with_media(config["saveLocation"]+config["filename"],config["text"])
published = True
os.remove(config["saveLocation"]+config["filename"])
except:
continue
break
if not(published):
print("Auth error")
else:
print("Error creating image\n")
print(status)