From 0ea90b5cd297e76bbf12483d56073f004d402fa1 Mon Sep 17 00:00:00 2001 From: Interitio Date: Mon, 1 Sep 2025 19:41:19 +1000 Subject: [PATCH] Annotate component. --- subathon/component.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/subathon/component.py b/subathon/component.py index 0cc1519..0d83f93 100644 --- a/subathon/component.py +++ b/subathon/component.py @@ -15,12 +15,22 @@ from .data import SubathonData, Subathon, RunningSubathon, SubathonContribution, class TimerChannel(Channel): + # TODO: Replace the channel mechanism? + # Or at least allow the subscriber to select the communityid on connection + # Eventually want to replace with a mechanism where clients subscribe to + # scoped events (e.g. just subtimer/channel) + # This subscription can be handled by a dedicated local client which has the registry + # Or the registry itself + # And then update hooks send the subscribers the information as a well-defined payload. + # Subscribers might want to communicate as well.. + # Each module can have a tiny client that handles it? A bit like this channel... name = 'Timer' def __init__(self, cog: 'SubathonComponent', **kwargs): super().__init__(**kwargs) self.cog = cog + # TODO: ... self.communityid = 1 async def on_connection(self, websocket, event): @@ -61,6 +71,8 @@ class TimerChannel(Channel): class ActiveSubathon: + # TODO: Version check + # Relies on event tracker and profiles module as well. def __init__(self, subathondata: Subathon, runningdata: RunningSubathon | None): self.subathondata = subathondata self.runningdata = runningdata @@ -85,6 +97,7 @@ class ActiveSubathon: new_duration = self.get_duration() await self.subathondata.update(duration=new_duration) await self.runningdata.delete() + self.runningdata = None async def resume(self): if self.running: @@ -356,7 +369,6 @@ class SubathonComponent(cmds.Component): @cmds.group(name='subathon', aliases=['studython'], 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: @@ -383,6 +395,7 @@ class SubathonComponent(cmds.Component): @group_subathon.command(name='setup') async def cmd_setup(self, ctx: cmds.Context, initial_hours: float, sub1: float, sub2: float, sub3: float, bit: float, timescore: int, timecap: Optional[int]=None): if ctx.broadcaster: + # TODO: Usage. Maybe implement ? commands? 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: