feat(twitch): Add focuswith command.

This commit is contained in:
2026-05-25 14:49:27 +03:00
parent d2050ab2dc
commit 869b401314
+35 -1
View File
@@ -238,7 +238,7 @@ class FocusComponent(cmds.Component):
"Use !unfocus to come back if you need to, best of luck! ☘️🍀☘️ "
)
@cmds.command(name="unfocus", aliases=["uncrocus"])
@cmds.command(name="unfocus", aliases=["uncrocus", "unhyper", "unhyperfocus"])
async def unfocus_cmd(self, ctx):
profile = await self.bot.profiles.fetch_profile(ctx.chatter, touch=True)
async with self.hyperfocus_lock:
@@ -273,6 +273,40 @@ class FocusComponent(cmds.Component):
else:
await ctx.reply(f"{user.name} is not hyperfocused!")
@cmds.command(name="focuswith", aliases=["hyperfocuswith"])
async def focuswith_cmd(self, ctx, user: twitchio.User):
profile = await self.bot.profiles.fetch_profile(ctx.chatter, touch=False)
pid = profile.profileid
tprofile = await self.bot.profiles.fetch_profile(user, touch=False)
tpid = tprofile.profileid
now = utc_now()
if hyper := await self.get_hyperfocus(tpid):
async with self.hyperfocus_lock:
end_at = hyper.ends_at
# Update the row
comm = await self.bot.profiles.fetch_community(
ctx.broadcaster, touch=True
)
await Hyperfocuser.table.delete_where(profileid=pid)
focuser = await Hyperfocuser.create(
profileid=pid,
started_at=now,
ends_at=end_at,
started_in=comm.communityid,
)
await self.dispatch_focuser_update(pid, comm.communityid, focuser)
durstr = strfdelta(end_at - now)
await ctx.reply(
f"{ctx.chatter.name} follows {user.name} into HYPERFOCUS for the next {durstr}!"
"Best of luck! ☘️🍀☘️ "
)
@cmds.command(name="addfocus")
async def addfocus_cmd(self, ctx):
await ctx.reply(