From 122dcfca3e0cc8925dce2056c063b03c4710e36c Mon Sep 17 00:00:00 2001 From: Interitio Date: Mon, 28 Jul 2025 14:05:51 +1000 Subject: [PATCH] Add status text. --- src/modules/subathons/component.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/modules/subathons/component.py b/src/modules/subathons/component.py index 619c6b4..39853d0 100644 --- a/src/modules/subathons/component.py +++ b/src/modules/subathons/component.py @@ -136,6 +136,7 @@ class SubathonComponent(cmds.Component): sender=self.bot.bot_id ) # TODO: Websocket update + await self.goalcheck() # Check goals @cmds.Component.listener() @@ -175,6 +176,7 @@ class SubathonComponent(cmds.Component): ) # TODO: Websocket update # Check goals + await self.goalcheck() @cmds.Component.listener() async def event_safe_subscription_gift(self, payload): @@ -209,6 +211,7 @@ class SubathonComponent(cmds.Component): ) # TODO: Websocket update # Check goals + await self.goalcheck() # end stream => Automatically pause the timer @cmds.Component.listener() @@ -229,7 +232,27 @@ class SubathonComponent(cmds.Component): @cmds.group(name='subathon', invoke_fallback=True) async def group_subathon(self, ctx: cmds.Context): # TODO: Status - ... + community = await self.bot.community_fetch(twitchid=ctx.broadcaster.id, name=ctx.broadcaster.name) + cid = community.communityid + if (active := await self.get_active_subathon(cid)) is not None: + score = await active.get_score() + goals = await active.get_goals() + total_goals = len(goals) + donegoals = len([goal for goal in goals if score >= goal.required_score]) + goalstr = f"{donegoals}/{total_goals} achieved!" + + secs = await active.get_remaining() + remaining = strfdelta(timedelta(seconds=secs)) + + secs = active.get_duration() + duration = strfdelta(timedelta(seconds=secs)) + + text = ( + f"Subathon running for {duration}! {score} (equivalent) subscriptions recieved, and {remaining} left on the timer" + ) + await ctx.reply(text) + else: + await ctx.reply("No active subathon running!") # subathon start @group_subathon.command(name='setup')