mirror of https://github.com/signalnine/lofi-imgen
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
676 B
Python
28 lines
676 B
Python
#!/usr/bin/env python3
|
|
|
|
import tweepy
|
|
from dotenv import load_dotenv
|
|
import os
|
|
import sys
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--filename", type=str)
|
|
parser.add_argument("--prompt", type=str)
|
|
args = parser.parse_args()
|
|
load_dotenv()
|
|
|
|
# Authenticate to Twitter
|
|
auth = tweepy.OAuthHandler(os.getenv("APIKEY"), os.getenv("APISECRET"))
|
|
auth.set_access_token(os.getenv("TOKEN"), os.getenv("TOKENSECRET"))
|
|
|
|
# Create API object
|
|
api = tweepy.API(auth)
|
|
|
|
# Create a tweet
|
|
media = api.media_upload(args.filename)
|
|
alt_text = api.create_media_metadata(media.media_id, args.prompt)
|
|
tweet = ""
|
|
api.update_status(status=tweet, media_ids=[media.media_id])
|
|
|