aboutsummaryrefslogtreecommitdiffstats
path: root/bot.py
blob: 7161ce5045f798f8a7da4b434f01b977a69ae065 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
os.chdir("/home/eden/yaoi-communism")

from twython import Twython
import get_images

twitter = Twython(*get_images.CONFIG["twitterapi"].values())

def post():
    images = get_images.main()
    while images is None:
        images = get_images.main()
    impath, source, text = images
    with open(impath, "rb") as img:
        response = twitter.upload_media(media = img)
        message = f"{text} ({source})"
        out = twitter.update_status(status=message, media_ids=[response["media_id"]])

    get_images.logging.info("Posted to twitter.")

if __name__ == "__main__":
    post()