From 8dd718cd208e1e6c6af6bd4287d9fb4c0e00b951 Mon Sep 17 00:00:00 2001 From: Kay Faraday Date: Wed, 11 Jan 2023 06:56:01 +0000 Subject: [PATCH] initial commit --- .gitignore | 1 + delete_posts.py | 38 ++++++++++++++++++++++++++++++++++++++ requirements.txt | 1 + 3 files changed, 40 insertions(+) create mode 100644 .gitignore create mode 100755 delete_posts.py create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c18dd8d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/ diff --git a/delete_posts.py b/delete_posts.py new file mode 100755 index 0000000..bc768f2 --- /dev/null +++ b/delete_posts.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +from pleroma import Pleroma + +class PostDeleter: + def __init__(self, *, access_token, api_base_url): + self._fedi = Pleroma(access_token=access_token, api_base_url=api_base_url) + + async def __aenter__(self): + self._fedi = await self._fedi.__aenter__() + return self + + async def __aexit__(self, *excinfo): + await self._fedi.__aexit__(*excinfo) + + async def run(self): + print('Deleting...') + async for status in self._fedi.account_statuses_iter( + await self._fedi.me(), + exclude_repeats=False, + ): + if status['reblog']: + await self._fedi.un_repeat(status['reblog']) + else: + await self._fedi.delete_status(status) + + print('.', end='', flush=True) + + print() + +async def main(): + import os, sys + async with PostDeleter(access_token=os.environ['ACCESS_TOKEN'], api_base_url=sys.argv[1]) as pd: + await pd.run() + +if __name__ == '__main__': + import anyio + anyio.run(main) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f022899 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pleroma.py