diff --git a/data/subathon.sql b/data/subathon.sql index ecc817d..5569318 100644 --- a/data/subathon.sql +++ b/data/subathon.sql @@ -9,6 +9,7 @@ CREATE TABLE subathons( communityid INTEGER NOT NULL REFERENCES communities(communityid), started_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), initial_time INTEGER NOT NULL, + name TEXT, sub1_score NUMERIC NOT NULL DEFAULT 1, sub2_score NUMERIC NOT NULL DEFAULT 2, sub3_score NUMERIC NOT NULL DEFAULT 6, diff --git a/subathon/component.py b/subathon/component.py index 6249717..0532b88 100644 --- a/subathon/component.py +++ b/subathon/component.py @@ -85,6 +85,10 @@ class ActiveSubathon: def running(self): return self.runningdata is not None + @property + def name(self): + return self.subathondata.name or 'Subathon' + async def check_cap(self): if not (cap := self.subathondata.timecap): return False @@ -385,7 +389,7 @@ class SubathonComponent(cmds.Component): duration = strfdelta(timedelta(seconds=secs)) text = ( - f"Subathon running for {duration}! {score} points recieved, {goalstr}, and {remaining} left on the timer" + f"{active.name} running for {duration}! {score} points recieved, {goalstr}, and {remaining} left on the timer" ) await ctx.reply(text) else: @@ -393,7 +397,7 @@ class SubathonComponent(cmds.Component): # subathon start @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): + async def cmd_setup(self, ctx: cmds.Context, name: str, 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.profiles.fetch_community(ctx.broadcaster) @@ -405,6 +409,7 @@ class SubathonComponent(cmds.Component): active = await Subathon.create( communityid=cid, + name=name, initial_time=initial_time, sub1_score=sub1, sub2_score=sub2, @@ -414,7 +419,7 @@ class SubathonComponent(cmds.Component): timecap=timecap ) timer_link = f"https://izashi.thewisewolf.dev/tracker/timer?channelid={ctx.channel.id}" - await ctx.reply(f"Setup a new subathon! Use !subathon resume to get the timer running. Your timer link: {timer_link}") + await ctx.reply(f"Setup your {name}! Use !subathon resume to get the timer running. Your timer link: {timer_link}") await self.channel.send_updates(cid) # subathon stop @@ -433,7 +438,7 @@ class SubathonComponent(cmds.Component): dur = strfdelta(timedelta(seconds=dursecs)) await ctx.reply( - f"Subathon complete after {dur} with a total of {total} points, congratulations!" + f"{active.name} complete after {dur} with a total of {total} points, congratulations!" ) else: await ctx.reply("No active subathon to stop.") @@ -447,10 +452,10 @@ class SubathonComponent(cmds.Component): if (active := await self.get_active_subathon(cid)) is not None: if active.running: await active.pause() - await ctx.reply("Subathon timer paused!") + await ctx.reply(f"{active.name} timer paused!") await self.channel.send_updates(cid) else: - await ctx.reply("Subathon timer already paused!") + await ctx.reply(f"{active.name} timer already paused!") else: await ctx.reply("No active subathon to pause") @@ -463,10 +468,10 @@ class SubathonComponent(cmds.Component): if (active := await self.get_active_subathon(cid)) is not None: if not active.running: await active.resume() - await ctx.reply("Subathon timer resumed!") + await ctx.reply(f"{active.name} timer resumed!") await self.channel.send_updates(cid) else: - await ctx.reply("Subathon timer already running!") + await ctx.reply(f"{active.name} timer already running!") else: await ctx.reply("No active subathon to resume") @@ -479,12 +484,12 @@ class SubathonComponent(cmds.Component): goals = await active.get_goals() goalstrs = [] for i, goal in enumerate(goals, start=1): - line = f"{goal.required_score} subs: {goal.description}" + line = f"{goal.required_score} points: {goal.description}" goalstrs.append(line) if goals: text = ', '.join(goalstrs) - await ctx.reply(f"Subathon Goals! -- {text}") + await ctx.reply(f"{active.name} Goals! -- {text}") else: await ctx.reply("No goals have been configured!") else: @@ -504,3 +509,5 @@ class SubathonComponent(cmds.Component): await ctx.reply("Goal added!") else: await ctx.reply("No active subathon to add goal to!") + + # TODO: diff --git a/subathon/data.py b/subathon/data.py index 2c5f8ac..82f72d6 100644 --- a/subathon/data.py +++ b/subathon/data.py @@ -11,6 +11,7 @@ class Subathon(RowModel): subathon_id = Integer(primary=True) communityid = Integer() started_at = Timestamp() + name = String() initial_time = Integer() # Initial number of seconds sub1_score = Integer() sub2_score = Integer()