excepted 2 Mastodon Errors
This commit is contained in:
parent
f2d82285af
commit
c8e9d7fd7a
38
retootbot.py
38
retootbot.py
|
@ -82,22 +82,28 @@ class RetootBot(object):
|
||||||
|
|
||||||
# boost mentions
|
# boost mentions
|
||||||
retoots = []
|
retoots = []
|
||||||
for notification in self.m.notifications():
|
try:
|
||||||
if (notification['type'] == 'mention'
|
for notification in self.m.notifications():
|
||||||
and notification['status']['id'] not in self.seen_toots):
|
if (notification['type'] == 'mention'
|
||||||
self.seen_toots.add(notification['status']['id'])
|
and notification['status']['id'] not in self.seen_toots):
|
||||||
text_content = re.sub(r'<[^>]*>', '',
|
self.seen_toots.add(notification['status']['id'])
|
||||||
notification['status']['content'])
|
text_content = re.sub(r'<[^>]*>', '',
|
||||||
if not self.filter.is_ok(text_content):
|
notification['status']['content'])
|
||||||
continue
|
if not self.filter.is_ok(text_content):
|
||||||
self.log('Boosting toot %d from %s: %s' % (
|
continue
|
||||||
notification['status']['id'],
|
self.log('Boosting toot %d from %s: %s' % (
|
||||||
notification['status']['account']['acct'],
|
notification['status']['id'],
|
||||||
notification['status']['content']))
|
notification['status']['account']['acct'],
|
||||||
self.m.status_reblog(notification['status']['id'])
|
notification['status']['content']))
|
||||||
retoots.append('%s: %s' % (
|
self.m.status_reblog(notification['status']['id'])
|
||||||
notification['status']['account']['acct'],
|
retoots.append('%s: %s' % (
|
||||||
re.sub(r'@\S*', '', text_content)))
|
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
|
# save state
|
||||||
with os.fdopen(os.open('seen_toots.pickle.part', os.O_WRONLY | os.O_EXCL | os.O_CREAT), 'w') as f:
|
with os.fdopen(os.open('seen_toots.pickle.part', os.O_WRONLY | os.O_EXCL | os.O_CREAT), 'w') as f:
|
||||||
|
|
Loading…
Reference in a new issue