Catch exceptions from HTTP request
We don't need to stop the entire process just because we encountered a temporary error.
This commit is contained in:
parent
96fd7ed430
commit
076b41e853
6
reply.py
6
reply.py
|
@ -4,7 +4,7 @@
|
|||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import mastodon
|
||||
import os, random, re, json
|
||||
import os, random, re, json, traceback
|
||||
import create
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
@ -49,7 +49,11 @@ class ReplyListener(mastodon.StreamListener):
|
|||
visibility = notification['status']['visibility']
|
||||
if visibility == "public":
|
||||
visibility = "unlisted"
|
||||
try:
|
||||
client.status_post(toot, post_id, visibility=visibility)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
else:
|
||||
print("replied with " + toot)
|
||||
|
||||
rl = ReplyListener()
|
||||
|
|
Reference in New Issue