ljfbot/ljfbot.py

43 lines
1.1 KiB
Python
Raw Normal View History

#!/usr/bin/env python
2022-11-23 00:55:53 -08:00
import random
from mastodon import Mastodon
import os
2023-01-11 16:19:04 -08:00
import json5 as json
2022-11-23 00:55:53 -08:00
2023-01-11 16:19:04 -08:00
with open('config.json') as f:
config = json.load(f)
2022-11-23 00:55:53 -08:00
mastodon = Mastodon(
2023-01-11 16:19:04 -08:00
access_token=config['access_token'],
api_base_url=config['site'],
2022-11-23 00:55:53 -08:00
)
with open('adjectives.txt') as f:
adjectives = list(map(str.rstrip, f))
with open('verbs.txt') as f:
verbs = list(map(str.rstrip, f))
postform = random.choice((
'{adjective} {gender} who {verb}',
'{adjective} {gender}',
'{gender} who {verb}',
))
2023-01-11 16:19:04 -08:00
gender = random.choice(('lgf', 'lbf', 'lef'))
2022-11-23 00:55:53 -08:00
verb = random.choice(verbs)
if verb[-2:] == 'ed' and verb[-3] not in {'a', 'e', 'i', 'o', 'u'}:
verb = verb[:-2]
if verb[-1] in {'a', 'i', 'o', 'u'}:
2022-11-23 00:55:53 -08:00
verb = verb + 'es'
2023-01-11 20:55:56 -08:00
elif verb[-1] in {'s', 'x'} or verb[-2] in {'s', 'x'} or verb[-2:] == 'ch':
2022-11-23 00:55:53 -08:00
verb = verb + 'es'
elif verb[-1] == 'y' and verb[-2] not in {'a', 'e', 'i', 'o', 'u'}:
2022-11-23 00:55:53 -08:00
verb = verb[:-1] + 'ies'
else:
verb = verb + 's'
adjective = random.choice(adjectives)
content = postform.format(adjective=adjective, gender=gender, verb=verb)
2022-11-23 00:55:53 -08:00
print(content)
mastodon.status_post(content, visibility='unlisted')