33 lines
990 B
Python
33 lines
990 B
Python
|
import random
|
||
|
import yaml
|
||
|
from mastodon import Mastodon
|
||
|
|
||
|
|
||
|
with open("mastodon.yml", "r") as config_file:
|
||
|
try:
|
||
|
mastodon_data = yaml.safe_load(config_file)
|
||
|
except yaml.YAMLError as e:
|
||
|
print(f"Scooter says: YAML error in config loading, hyper hyper! {e}")
|
||
|
exit(1)
|
||
|
|
||
|
mastodon = Mastodon(
|
||
|
access_token=mastodon_data.get("token"),
|
||
|
api_base_url=mastodon_data.get("url")
|
||
|
)
|
||
|
|
||
|
with open("lyrics.yml", "r") as lyrics_file:
|
||
|
try:
|
||
|
lines = yaml.safe_load(lyrics_file)
|
||
|
except yaml.YAMLError as e:
|
||
|
print(f"Scooter alert: YAML mix-up in lyrics! Call the doctor! {e}")
|
||
|
exit(1)
|
||
|
|
||
|
output = random.choice(lines.get("quotes", []))
|
||
|
|
||
|
visibility = 'public' if random.random() >= 0.9 else 'unlisted'
|
||
|
|
||
|
try:
|
||
|
mastodon.status_post(output, visibility=visibility)
|
||
|
print("Success! Our post has rocked the Mastodon stage!")
|
||
|
except Exception as e:
|
||
|
print(f"Scooter check: Something went bonkers with the Mastodon post! How much is the fish? {e}")
|