excepted 2 Mastodon Errors

This commit is contained in:
b3yond 2017-10-02 20:12:58 +02:00
parent f2d82285af
commit c8e9d7fd7a

View file

@ -82,6 +82,7 @@ class RetootBot(object):
# boost mentions
retoots = []
try:
for notification in self.m.notifications():
if (notification['type'] == 'mention'
and notification['status']['id'] not in self.seen_toots):
@ -98,6 +99,11 @@ class RetootBot(object):
retoots.append('%s: %s' % (
notification['status']['account']['acct'],
re.sub(r'@\S*', '', text_content)))
# If the Mastodon instance returns interesting Errors, add them here:
except mastodon.MastodonAPIError:
self.log("There was a Mastodon API Error, probably the API is not available.")
except mastodon.MastodonNetworkError:
self.log("There was a Mastodon Network Error, could not reach the server.")
# save state
with os.fdopen(os.open('seen_toots.pickle.part', os.O_WRONLY | os.O_EXCL | os.O_CREAT), 'w') as f: