removed unused media code

This commit is contained in:
Lynne 2019-07-02 20:43:34 +10:00
parent 0ceb255865
commit cd659d86a1
3 changed files with 6 additions and 16 deletions

View File

@ -61,10 +61,7 @@ def make_toot_markov(query = None):
if toot == None: if toot == None:
toot = "Toot generation failed! Contact Lynne (lynnesbian@fedi.lynnesbian.space) for assistance." toot = "Toot generation failed! Contact Lynne (lynnesbian@fedi.lynnesbian.space) for assistance."
return { return toot
"toot": toot,
"media": None
}
def extract_toot(toot): def extract_toot(toot):
toot = html.unescape(toot) #convert HTML escape codes to text toot = html.unescape(toot) #convert HTML escape codes to text

13
gen.py
View File

@ -30,18 +30,11 @@ if __name__ == '__main__':
toot = re.sub(r"[\[\]\(\)\{\}\"“”«»„]", "", toot) toot = re.sub(r"[\[\]\(\)\{\}\"“”«»„]", "", toot)
if not args.simulate: if not args.simulate:
try: 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: 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!") client.status_post(toot['toot'], visibility = 'unlisted', spoiler_text = "Error!")
try: try:
print(toot['toot']) print(toot)
except UnicodeEncodeError: 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

View File

@ -67,7 +67,7 @@ class ReplyListener(mastodon.StreamListener):
else: else:
print("User is not valid") print("User is not valid")
else: else:
toot = functions.make_toot(True)['toot'] #generate a toot toot = functions.make_toot(True) #generate a toot
toot = acct + " " + toot #prepend the @ toot = acct + " " + toot #prepend the @
print(acct + " says " + mention) #logging print(acct + " says " + mention) #logging
visibility = notification['status']['visibility'] visibility = notification['status']['visibility']