simplify delete_posts and get rid of the class
This commit is contained in:
parent
fbac5933db
commit
c2ce186e8c
|
@ -2,36 +2,20 @@
|
||||||
|
|
||||||
from pleroma import Pleroma
|
from pleroma import Pleroma
|
||||||
|
|
||||||
class PostDeleter:
|
async def main():
|
||||||
def __init__(self, *, access_token, api_base_url):
|
import os, sys
|
||||||
self._fedi = Pleroma(access_token=access_token, api_base_url=api_base_url)
|
async with Pleroma(access_token=os.environ['ACCESS_TOKEN'], api_base_url=sys.argv[1]) as fedi:
|
||||||
|
|
||||||
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...')
|
print('Deleting...')
|
||||||
async for status in self._fedi.account_statuses_iter(
|
async for status in fedi.account_statuses_iter(await fedi.me(), exclude_repeats=False):
|
||||||
await self._fedi.me(),
|
|
||||||
exclude_repeats=False,
|
|
||||||
):
|
|
||||||
if status['reblog']:
|
if status['reblog']:
|
||||||
await self._fedi.un_repeat(status['reblog'])
|
await fedi.un_repeat(status['reblog'])
|
||||||
else:
|
else:
|
||||||
await self._fedi.delete_status(status)
|
await fedi.delete_status(status)
|
||||||
|
|
||||||
print('.', end='', flush=True)
|
print('.', end='', flush=True)
|
||||||
|
|
||||||
print()
|
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__':
|
if __name__ == '__main__':
|
||||||
import anyio
|
import anyio
|
||||||
|
|
Loading…
Reference in New Issue