diff --git a/bot/modules/study/tracking/commands.py b/bot/modules/study/tracking/commands.py index 0c64ffdf..c334e8b0 100644 --- a/bot/modules/study/tracking/commands.py +++ b/bot/modules/study/tracking/commands.py @@ -2,6 +2,7 @@ from cmdClient import Context from cmdClient.checks import in_guild from core import Lion +from wards import is_guild_admin from ..module import module @@ -13,22 +14,53 @@ MAX_TAG_LENGTH = 10 "now", group="Statistics", desc="What are you working on?", - aliases=('studying', 'workingon') + aliases=('studying', 'workingon'), + flags=('clear', 'new') ) @in_guild() -async def cmd_now(ctx: Context): +async def cmd_now(ctx: Context, flags): """ Usage``: {prefix}now [tag] {prefix}now @mention + {prefix}now --clear Description: Describe the subject or goal you are working on this session with, for example, `{prefix}now Maths`. Mention someone else to view what they are working on! + Flags:: + clear: Remove your current tag. Examples: > {prefix}now Biology > {prefix}now {ctx.author.mention} """ - if ctx.args: + if flags['clear']: + if ctx.msg.mentions and is_guild_admin(ctx.author): + # Assume an admin is trying to clear another user's tag + for target in ctx.msg.mentions: + lion = Lion.fetch(ctx.guild.id, target.id) + if lion.session: + lion.session.data.tag = None + + if len(ctx.msg.mentions) == 1: + await ctx.embed_reply( + f"Cleared session tags for {ctx.msg.mentions[0].mention}." + ) + else: + await ctx.embed_reply( + f"Cleared session tags for:\n{', '.join(target.mention for target in ctx.msg.mentions)}." + ) + else: + # Assume the user is clearing their own session tag + if (session := ctx.alion.session): + session.data.tag = None + await ctx.embed_reply( + "Removed your session study tag!" + ) + else: + await ctx.embed_reply( + "You aren't studying right now, so there is nothing to clear!" + ) + elif ctx.args: if ctx.msg.mentions: # Assume peeking at user's current session @@ -48,14 +80,14 @@ async def cmd_now(ctx: Context): return await ctx.embed_reply( "Thanks for asking!\n" f"I'm just helping out the **{student_count}** " - f"hardworking students currently studying across **{guild_count}** fun communities!\n" + f"dedicated people currently working across **{guild_count}** fun communities!\n" f"{tail}" ) lion = Lion.fetch(ctx.guild.id, target.id) if not lion.session: await ctx.embed_reply( - f"{target.mention} isn't studying right now!" + f"{target.mention} isn't working right now!" ) else: duration = lion.session.duration @@ -69,7 +101,7 @@ async def cmd_now(ctx: Context): if not lion.session.data.tag: await ctx.embed_reply( - f"{target.mention} has been studying in <#{lion.session.data.channelid}> for **{dur_str}**!" + f"{target.mention} has been working in <#{lion.session.data.channelid}> for **{dur_str}**!" ) else: await ctx.embed_reply( @@ -82,7 +114,7 @@ async def cmd_now(ctx: Context): if not (session := ctx.alion.session): return await ctx.error_reply( - "You aren't studying right now! Join a study channel and try again!" + "You aren't working right now! Join a study channel and try again!" ) if len(tag) > MAX_TAG_LENGTH: @@ -103,7 +135,6 @@ async def cmd_now(ctx: Context): ) else: # View current session, stats, and guide. - lines = [] if (session := ctx.alion.session): duration = session.duration if duration > 3600: @@ -115,11 +146,9 @@ async def cmd_now(ctx: Context): dur_str = "{} minutes".format(int((duration % 3600) / 60)) if not session.data.tag: await ctx.embed_reply( - f"You have been studying in <#{session.data.channelid}> for **{dur_str}**!" - ) - lines.append( + f"You have been working in <#{session.data.channelid}> for **{dur_str}**!\n" f"Describe what you are working on with " - "`{ctx.best_prefix}now `, e.g. `{ctx.best_prefix}now Maths`!" + f"`{ctx.best_prefix}now `, e.g. `{ctx.best_prefix}now Maths`" ) else: await ctx.embed_reply( @@ -128,7 +157,7 @@ async def cmd_now(ctx: Context): ) else: await ctx.embed_reply( - f"Join a study channel and describe what you are working on with e.g. `{ctx.best_prefix}now Maths!`" + f"Join a study channel and describe what you are working on with e.g. `{ctx.best_prefix}now Maths`" ) # TODO: Favourite tags listing