aboutsummaryrefslogtreecommitdiffstats
path: root/bot.py
blob: 27a5f3a12e1e1ed3f07be5e1bfffef3826c1580b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from twython import Twython
import get_images

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

def post():
    impath, source, text = get_images.main()
    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__":
    import time

    while True:
        post()
        time.sleep(60*60)