start work on generating thoughts
This commit is contained in:
parent
d8babf206a
commit
556bcefa33
1 changed files with 33 additions and 13 deletions
46
post.py
Normal file → Executable file
46
post.py
Normal file → Executable file
|
@ -16,19 +16,39 @@
|
|||
from mastodon import Mastodon
|
||||
import json, random
|
||||
|
||||
try:
|
||||
cfg = json.load(open('config.json', 'r'))
|
||||
except:
|
||||
print("Couldn't load config.json. Make sure you run main.py first!\n-----")
|
||||
raise
|
||||
meta = json.load(open('meta.json', 'r'))
|
||||
# try:
|
||||
# cfg = json.load(open('config.json', 'r'))
|
||||
# except:
|
||||
# print("Couldn't load config.json. Make sure you run main.py first!\n-----")
|
||||
# raise
|
||||
# meta = json.load(open('meta.json', 'r'))
|
||||
|
||||
# log in
|
||||
client = Mastodon(
|
||||
client_id=cfg['client']['id'],
|
||||
client_secret=cfg['client']['secret'],
|
||||
access_token=cfg['secret'],
|
||||
api_base_url=cfg['site'])
|
||||
# # log in
|
||||
# client = Mastodon(
|
||||
# client_id=cfg['client']['id'],
|
||||
# client_secret=cfg['client']['secret'],
|
||||
# access_token=cfg['secret'],
|
||||
# api_base_url=cfg['site'])
|
||||
|
||||
# make a post!
|
||||
# if you delete this line, you can also remove the random module from the imports list.
|
||||
data = json.load(open('data.json', 'r'))
|
||||
|
||||
def get_object(kind):
|
||||
num = random.choice([1, 1, 1, 1, 1, 2, 2, 3])
|
||||
if kind == "rides":
|
||||
return "{} {}".format(random.choice(data['objects']['thrilling-rides'] + data['objects']['gentle-rides']), num)
|
||||
|
||||
thoughts_weighted = []
|
||||
for key in data['thoughts']:
|
||||
for i in range(len(data['thoughts'][key])):
|
||||
thoughts_weighted.append(key)
|
||||
|
||||
thought_type = random.choice(thoughts_weighted)
|
||||
thought_type = "rides"
|
||||
|
||||
thought = random.choice(data['thoughts'][thought_type])
|
||||
|
||||
if thought_type == "rides":
|
||||
thought = thought.format(get_object('rides'))
|
||||
|
||||
print(thought)
|
||||
|
|
Loading…
Reference in a new issue