FreakPositivity/freakpos.py

36 lines
959 B
Python
Executable File

#!/usr/bin/env python
import anyio
import qtoml
import random
import pleroma
def load_config():
with open('config.toml') as f:
return qtoml.load(f)
def load_static():
with open('messages2.txt') as f:
messages = list(map(str.rstrip, f))
with open('labels.txt') as f:
labels = list(map(str.rstrip, f))
return messages, labels
def gen_post(messages, labels):
message = random.choice(messages)
label = random.choice(labels)
message = message.format(label)
# believe me, there isn't already a string method that does this.
# not even .capitalize().
return message[0].upper() + message[1:]
async def main():
config = load_config()
static_data = load_static()
async with pleroma.Pleroma(api_base_url=config['site'], access_token=config['access_token']) as pl:
visibility = 'direct' if config.get('test_mode', False) else 'unlisted'
await pl.post(gen_post(*static_data), visibility=visibility)
if __name__ == '__main__':
anyio.run(main)