From 1c38aa94e8a5f68db410dc9a24e7bbeaf4b9a8fc Mon Sep 17 00:00:00 2001 From: Lynne Date: Fri, 20 Sep 2019 18:32:29 +1000 Subject: [PATCH] it is done --- meta.json | 6 +++--- post.py | 39 ++++++++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/meta.json b/meta.json index 994a789..6767d68 100644 --- a/meta.json +++ b/meta.json @@ -1,5 +1,5 @@ { - "bot_name": "My cool fedi bot", - "source_url": "https://github.com/Lynnesbian/fediverse-bot-template", - "admin": "you@your.instance" + "bot_name": "leftbot", + "source_url": "https://git.lynnesbian.space/lynnesbian/leftbot", + "admin": "lynnesbian@fedi.lynnesbian.space" } diff --git a/post.py b/post.py index a3edf00..2221dd6 100644 --- a/post.py +++ b/post.py @@ -13,14 +13,14 @@ # GNU Affero General Public License for more details. # import Mastodon.py and other modules -# from mastodon import Mastodon +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 login.py first!\n-----") -# raise +try: + cfg = json.load(open('config.json', 'r')) +except: + print("Couldn't load config.json. Make sure you run login.py first!\n-----") + raise meta = json.load(open('meta.json', 'r')) takes = json.load(open('takes.json')) @@ -34,15 +34,24 @@ take = random.choice(takes['templates']).format( ideolog = random.choice([i[:-1] + "t" for i in takes['ideologies'] if i.endswith("ism")]) ) +cw = random.choice(takes['content warnings']).format( + ideology = random.choice(takes['ideologies']), + ideology2 = random.choice(takes['ideologies']), + thing = random.choice(takes['things']), + thing2 = random.choice(takes['things']), + thing3 = random.choice(takes['things']), + site = random.choice(takes['sites']), + ideolog = random.choice([i[:-1] + "t" for i in takes['ideologies'] if i.endswith("ism")]) +) + print(take) -# # 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. -# client.status_post("Hi! Your random number is: {}".format(random.randint(0,10000))) +# make a post! +client.status_post(take, spoiler_text = cw)