mirror of
https://github.com/hughrun/ephemetoot
synced 2025-01-09 20:42:33 +01:00
add the ability to do a test run
This commit is contained in:
parent
6082441e9e
commit
a3b9fa6b56
@ -22,11 +22,20 @@
|
||||
# or email hugh [at] hughrundle [dot] net
|
||||
# #####################################################################
|
||||
|
||||
from argparse import ArgumentParser
|
||||
import config
|
||||
import json
|
||||
from mastodon import Mastodon
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--test", action="store_true", help="do a test run without deleting any toots"
|
||||
)
|
||||
options = parser.parse_args()
|
||||
if options.test:
|
||||
print("This is a test run...")
|
||||
|
||||
print("Fetching account details...")
|
||||
|
||||
mastodon = Mastodon(access_token=config.access_token, api_base_url=config.base_url)
|
||||
@ -62,7 +71,8 @@ def checkToots(timeline, deleted_count=0):
|
||||
+ toot.created_at.strftime("%d %b %Y")
|
||||
)
|
||||
deleted_count += 1
|
||||
mastodon.status_delete(toot)
|
||||
if not options.test:
|
||||
mastodon.status_delete(toot)
|
||||
except:
|
||||
print("🛑 **error** with toot - " + str(toot.id))
|
||||
|
||||
@ -75,7 +85,14 @@ def checkToots(timeline, deleted_count=0):
|
||||
if len(next_batch) > 0:
|
||||
checkToots(next_batch, deleted_count)
|
||||
else:
|
||||
print("Removed " + str(deleted_count) + " toots.")
|
||||
if options.test:
|
||||
print(
|
||||
"Test run. This would have removed "
|
||||
+ str(deleted_count)
|
||||
+ " toots."
|
||||
)
|
||||
else:
|
||||
print("Removed " + str(deleted_count) + " toots.")
|
||||
except IndexError:
|
||||
print("No toots found!")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user