Add status text.
This commit is contained in:
@@ -136,6 +136,7 @@ class SubathonComponent(cmds.Component):
|
|||||||
sender=self.bot.bot_id
|
sender=self.bot.bot_id
|
||||||
)
|
)
|
||||||
# TODO: Websocket update
|
# TODO: Websocket update
|
||||||
|
await self.goalcheck()
|
||||||
# Check goals
|
# Check goals
|
||||||
|
|
||||||
@cmds.Component.listener()
|
@cmds.Component.listener()
|
||||||
@@ -175,6 +176,7 @@ class SubathonComponent(cmds.Component):
|
|||||||
)
|
)
|
||||||
# TODO: Websocket update
|
# TODO: Websocket update
|
||||||
# Check goals
|
# Check goals
|
||||||
|
await self.goalcheck()
|
||||||
|
|
||||||
@cmds.Component.listener()
|
@cmds.Component.listener()
|
||||||
async def event_safe_subscription_gift(self, payload):
|
async def event_safe_subscription_gift(self, payload):
|
||||||
@@ -209,6 +211,7 @@ class SubathonComponent(cmds.Component):
|
|||||||
)
|
)
|
||||||
# TODO: Websocket update
|
# TODO: Websocket update
|
||||||
# Check goals
|
# Check goals
|
||||||
|
await self.goalcheck()
|
||||||
|
|
||||||
# end stream => Automatically pause the timer
|
# end stream => Automatically pause the timer
|
||||||
@cmds.Component.listener()
|
@cmds.Component.listener()
|
||||||
@@ -229,7 +232,27 @@ class SubathonComponent(cmds.Component):
|
|||||||
@cmds.group(name='subathon', invoke_fallback=True)
|
@cmds.group(name='subathon', invoke_fallback=True)
|
||||||
async def group_subathon(self, ctx: cmds.Context):
|
async def group_subathon(self, ctx: cmds.Context):
|
||||||
# TODO: Status
|
# 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
|
# subathon start
|
||||||
@group_subathon.command(name='setup')
|
@group_subathon.command(name='setup')
|
||||||
|
|||||||
Reference in New Issue
Block a user