1
0
Fork 0
fediverse-bots/morrowsay-bot/post.py

29 lines
597 B
Python
Raw Permalink Normal View History

2024-04-08 16:38:52 -04:00
import sys
import random
import datetime
import os.path as op
from pprint import pprint
import requests
from mastodon import Mastodon
# --------------------------------------------------
def main():
mastodon = Mastodon(
access_token = 'token.dat',
api_base_url = 'https://your.site/'
)
with open('quotes.dat', 'r', encoding='utf-8') as file:
data = file.readlines()
quote = data[random.randint(0, len(data))]
toot = quote
mastodon.status_post(toot, media_ids=None, visibility='unlisted')
if __name__ == '__main__':
sys.exit(main())