mirror of
https://gitlab.com/oloturia/fumcaso.git
synced 2025-01-08 06:27:17 +01:00
Added a twitter bot
This commit is contained in:
parent
b8df46d284
commit
28d6f3cc3b
1 changed files with 26 additions and 0 deletions
26
twitter_main.py
Executable file
26
twitter_main.py
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/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)
|
||||
try:
|
||||
api.verify_credentials()
|
||||
print("Auth OK")
|
||||
api.update_with_media(fileDir+"twitter.png","Generatore automatico di strip. Striscia di oggi.")
|
||||
except:
|
||||
print("Auth error")
|
||||
else:
|
||||
print("Error creating image\n")
|
||||
print(status)
|
Loading…
Reference in a new issue