wirtes / semantic-distorter

Plays a game of "telephone" by translating a string through many languages to generate something of obfuscated meaning.
0 stars 0 forks source link

Error after reboot & replies are queued #2

Open wirtes opened 11 months ago

wirtes commented 11 months ago

autoresponder.py doesn't function correctly after a reboot if there are replies queued up. Put differently, after a reboot, if autoresponder.py finds a message waiting, it errors and stops running. This is the error:

Traceback (most recent call last):
  File "/home/pi/botcode/./autoresponder.py", line 174, in <module>
    respond_to_mentions(read_state())
  File "/home/pi/botcode/./autoresponder.py", line 157, in respond_to_mentions
    create_and_post_reply(soup.get_text().replace("@semantic_distorter", ""), mention.status.id, mention.account.acct)
  File "/home/pi/botcode/./autoresponder.py", line 94, in create_and_post_reply
    translated_text = semantic_distorter.translate(text_to_translate, translate_from_language, translate_to_language, config["translation_endpoint_url"])
  File "/home/pi/botcode/semantic_distorter.py", line 51, in translate
    return translated_object["translatedText"]
KeyError: 'translatedText'

Best guess is that libretranslate isn't ready yet.

wirtes commented 11 months ago

manually running autoresponder.py from the shell after reboot will clear the waiting replies & then it will function fine -- after another reboot to relaunch the cron.