From cd659d86a14f91f2a3754f996b617d5a5048590d Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 2 Jul 2019 20:43:34 +1000 Subject: [PATCH] removed unused media code --- functions.py | 5 +---- gen.py | 15 ++++----------- reply.py | 2 +- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/functions.py b/functions.py index ca75c3f..e971bd9 100755 --- a/functions.py +++ b/functions.py @@ -61,10 +61,7 @@ def make_toot_markov(query = None): if toot == None: toot = "Toot generation failed! Contact Lynne (lynnesbian@fedi.lynnesbian.space) for assistance." - return { - "toot": toot, - "media": None - } + return toot def extract_toot(toot): toot = html.unescape(toot) #convert HTML escape codes to text diff --git a/gen.py b/gen.py index 1671692..6671075 100755 --- a/gen.py +++ b/gen.py @@ -30,18 +30,11 @@ if __name__ == '__main__': toot = re.sub(r"[\[\]\(\)\{\}\"“”«»„]", "", toot) if not args.simulate: try: - if toot['media'] != None: - mediaID = client.media_post(toot['media'], description = toot['toot']) - client.status_post(toot['toot'].replace("\n", " "), - media_ids = [mediaID], visibility = "unlisted", spoiler_text = cfg['cw']) - else: - client.status_post(toot['toot'], visibility = 'unlisted', spoiler_text = cfg['cw']) + client.status_post(toot['toot'], visibility = 'unlisted', spoiler_text = cfg['cw']) except Exception as err: - toot = { - "toot": "An error occurred while submitting the generated post. Contact lynnesbian@fedi.lynnesbian.space for assistance." - } + toot = "An error occurred while submitting the generated post. Contact lynnesbian@fedi.lynnesbian.space for assistance." client.status_post(toot['toot'], visibility = 'unlisted', spoiler_text = "Error!") try: - print(toot['toot']) + print(toot) except UnicodeEncodeError: - print(toot['toot'].encode("ascii", "ignore")) # encode as ASCII, dropping any non-ASCII characters + print(toot.encode("ascii", "ignore")) # encode as ASCII, dropping any non-ASCII characters diff --git a/reply.py b/reply.py index ae0959e..80d4e58 100755 --- a/reply.py +++ b/reply.py @@ -67,7 +67,7 @@ class ReplyListener(mastodon.StreamListener): else: print("User is not valid") else: - toot = functions.make_toot(True)['toot'] #generate a toot + toot = functions.make_toot(True) #generate a toot toot = acct + " " + toot #prepend the @ print(acct + " says " + mention) #logging visibility = notification['status']['visibility']