From 2f1a34852ed38adcc996a5cf85e8f70aa08036e8 Mon Sep 17 00:00:00 2001 From: Mark Eaton Date: Mon, 13 May 2019 14:33:33 -0400 Subject: [PATCH 1/2] add notification when rate limit reached --- ephemetoot.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ephemetoot.py b/ephemetoot.py index ca61cf8..f96a08f 100644 --- a/ephemetoot.py +++ b/ephemetoot.py @@ -79,6 +79,8 @@ def checkToots(timeline, deleted_count=0): time.sleep( 2 ) # wait 2 secs between deletes to be a bit nicer to the server + if mastodon.ratelimit_remaining == 0: + print("Rate limit reached. Waiting for a rate limit reset...") if not options.test: mastodon.status_delete(toot) except MastodonError as e: From 6354876d536967636ede6af30f3b5f111378e7e3 Mon Sep 17 00:00:00 2001 From: Mark Eaton Date: Mon, 13 May 2019 15:32:10 -0400 Subject: [PATCH 2/2] make rate limit check only for non-test runs --- ephemetoot.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ephemetoot.py b/ephemetoot.py index f96a08f..f623004 100644 --- a/ephemetoot.py +++ b/ephemetoot.py @@ -67,6 +67,10 @@ def checkToots(timeline, deleted_count=0): deleted_count += 1 # unreblog the original toot (their toot), not the toot created by boosting (your toot) if not options.test: + if mastodon.ratelimit_remaining == 0: + print( + "Rate limit reached. Waiting for a rate limit reset..." + ) mastodon.status_unreblog(toot.reblog) else: print( @@ -79,9 +83,11 @@ def checkToots(timeline, deleted_count=0): time.sleep( 2 ) # wait 2 secs between deletes to be a bit nicer to the server - if mastodon.ratelimit_remaining == 0: - print("Rate limit reached. Waiting for a rate limit reset...") if not options.test: + if mastodon.ratelimit_remaining == 0: + print( + "Rate limit reached. Waiting for a rate limit reset..." + ) mastodon.status_delete(toot) except MastodonError as e: print("🛑 ERROR deleting toot - " + str(toot.id) + " - " + e.args[3])