Lilac subathon customisations

This commit is contained in:
2026-07-22 17:28:10 +03:00
parent 11c77bcc89
commit 297eb434d4
2 changed files with 52 additions and 29 deletions
+35 -26
View File
@@ -96,7 +96,7 @@ class SubathonComponent(cmds.Component):
# Should probably wait on a central messaging slow-lock bucketed by channel instead
await asyncio.sleep(1)
await channel.send_message(
f"We have reached Goal #{i + 1}: {goal.description} !! Thank you everyone for your support <3",
f"We have reached Goal #{i + 1}: {goal.description} !! Thank you everyone for your support cutecat",
sender=self.bot.bot_id,
)
await goal.update(notified=True)
@@ -161,9 +161,9 @@ class SubathonComponent(cmds.Component):
contrib_str = f"{name} contributed {score} point{pl}"
if not await active.check_cap():
contrib_str += f" and added {added} to the timer! Thank you <3"
contrib_str += f" and added {added} to the timer! Thank you cutecat"
else:
contrib_str += " towards our subathon! Thank you <3"
contrib_str += " towards our subathon! Thank you cutecat"
await bits_payload.broadcaster.send_message(
contrib_str, sender=self.bot.bot_id
@@ -211,9 +211,9 @@ class SubathonComponent(cmds.Component):
contrib_str = f"{name} contributed {score} point{pl}"
if not await active.check_cap():
contrib_str += f" and added {added} to the timer! Thank you <3"
contrib_str += f" and added {added} to the timer! Thank you cutecat"
else:
contrib_str += " towards our subathon! Thank you <3"
contrib_str += " towards our subathon! Thank you cutecat"
await sub_payload.broadcaster.send_message(
contrib_str, sender=self.bot.bot_id
@@ -257,9 +257,9 @@ class SubathonComponent(cmds.Component):
contrib_str = f"{name} contributed {score} points"
if not await active.check_cap():
contrib_str += f" and added {added} to the timer! Thank you <3"
contrib_str += f" and added {added} to the timer! Thank you cutecat"
else:
contrib_str += " towards our subathon! Thank you <3"
contrib_str += " towards our subathon! Thank you cutecat"
await gift_payload.broadcaster.send_message(
contrib_str, sender=self.bot.bot_id
@@ -289,7 +289,8 @@ class SubathonComponent(cmds.Component):
else:
raise ValueError(f"Unknown sub tier {sub_payload.tier}")
score = mult * 1
# score = mult * 1
score = 0
logger.info(
f"Adding subathon contribution from subscription message payload {payload}"
@@ -304,13 +305,13 @@ class SubathonComponent(cmds.Component):
contrib_str = f"{name} contributed {score} points{pl}"
if not await active.check_cap():
contrib_str += f" and added {added} to the timer! Thank you <3"
contrib_str += f" and added {added} to the timer! Thank you cutecat"
else:
contrib_str += " towards our subathon! Thank you <3"
contrib_str += " towards our subathon! Thank you cutecat"
await sub_payload.broadcaster.send_message(
contrib_str, sender=self.bot.bot_id
)
# await sub_payload.broadcaster.send_message(
# contrib_str, sender=self.bot.bot_id
# )
await self.dispatch_update(active)
# Check goals
await self.goalcheck(active, sub_payload.broadcaster)
@@ -335,7 +336,7 @@ class SubathonComponent(cmds.Component):
# ----- Commands -----
@cmds.group(name="subathon", aliases=["studython"], invoke_fallback=True)
@cmds.group(name="subathon", aliases=["studython", "suba"], invoke_fallback=True)
async def group_subathon(self, ctx: cmds.Context):
community = await self.bot.profiles.fetch_community(ctx.broadcaster)
cid = community.communityid
@@ -821,26 +822,34 @@ class SubathonComponent(cmds.Component):
await ctx.reply("No active subathon to show leaderboard of!")
# Subathon goals
@cmds.group(name="goals", invoke_fallback=True)
async def group_goals(self, ctx: cmds.Context):
# List the goals
@cmds.command(name="subnext", aliases=("nextgoal",))
async def cmd_goals_nextgoal(self, ctx: cmds.Context, *, args: str):
if args.lower().split()[0] != 'goal':
return
community = await self.bot.profiles.fetch_community(ctx.broadcaster)
cid = community.communityid
if (active := await self.get_active_subathon(cid)) is not None:
score = await active.get_score()
goals = await active.get_goals()
goalstrs = []
for i, goal in enumerate(goals, start=1):
line = f"{goal.required_score} points: {goal.description}"
goalstrs.append(line)
if goals:
text = ", ".join(goalstrs)
await ctx.reply(f"{active.name} Goals! -- {text}")
nextgoal = next(
(goal for goal in goals if goal.required_score > score),
None
)
if nextgoal is None:
# None message
await ctx.reply("We have achieved all our goals for this subathon!")
else:
await ctx.reply("No goals have been configured!")
await ctx.reply(
f"Gift {nextgoal.required_score - score} points for next goal: {nextgoal.description}"
)
else:
await ctx.reply("No active subathon running!")
@cmds.group(name="subagoals")
async def group_goals(self, ctx: cmds.Context):
...
@group_goals.command(name="remaining", aliases=("left",))
async def cmd_goals_remaining(self, ctx: cmds.Context):
community = await self.bot.profiles.fetch_community(ctx.broadcaster)