deduplicate command handler logic
This commit is contained in:
parent
40fad78407
commit
f593af4fa2
|
@ -21,14 +21,18 @@ async def main():
|
||||||
anyio.create_task_group() as nursery,
|
anyio.create_task_group() as nursery,
|
||||||
):
|
):
|
||||||
async for notif in pleroma.stream_notifications():
|
async for notif in pleroma.stream_notifications():
|
||||||
|
handler = None
|
||||||
if 'opt out' in notif['status']['content']:
|
if 'opt out' in notif['status']['content']:
|
||||||
nursery.start_soon(opt_out, db, pleroma, notif['status'])
|
handler = opt_out
|
||||||
elif 'opt in' in notif['status']['content']:
|
elif 'opt in' in notif['status']['content']:
|
||||||
nursery.start_soon(opt_in, db, pleroma, notif['status'])
|
handler = opt_in
|
||||||
elif 'status' in notif['status']['content']:
|
elif 'status' in notif['status']['content']:
|
||||||
nursery.start_soon(status, db, pleroma, notif['status'])
|
handler = status
|
||||||
elif 'help' in notif['status']['content']:
|
elif 'help' in notif['status']['content']:
|
||||||
nursery.start_soon(help, db, pleroma, notif['status'])
|
handler = help
|
||||||
|
|
||||||
|
if handler:
|
||||||
|
nursery.start_soon(handler, db, pleroma, notif['status'])
|
||||||
|
|
||||||
async def opt_out(db, pleroma, status):
|
async def opt_out(db, pleroma, status):
|
||||||
await db.execute(
|
await db.execute(
|
||||||
|
|
Reference in New Issue