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:
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

13
gen.py
View file

@ -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'])
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

View file

@ -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']