From f593af4fa24ccc16f492cbc1b468a3127bc178cd Mon Sep 17 00:00:00 2001 From: Kay Faraday Date: Mon, 11 Sep 2023 18:22:24 +0000 Subject: [PATCH] deduplicate command handler logic --- opter_outer.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/opter_outer.py b/opter_outer.py index 8dfc177..7cab300 100755 --- a/opter_outer.py +++ b/opter_outer.py @@ -21,14 +21,18 @@ async def main(): anyio.create_task_group() as nursery, ): async for notif in pleroma.stream_notifications(): + handler = None 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']: - nursery.start_soon(opt_in, db, pleroma, notif['status']) + handler = opt_in elif 'status' in notif['status']['content']: - nursery.start_soon(status, db, pleroma, notif['status']) + handler = status 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): await db.execute(