Skip to content

Commit 0e131fe

Browse files
author
Paul Philion
committed
renaming to /hours, updating formatting
1 parent dbc1aee commit 0e131fe

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

docs/devlog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 2025-09-08, v0.5
44

5-
Added `/record_time` command: Captures hours (float), program (popup selector based on /enumerations/time_entry_activities.json) ans an options note.
5+
Added `/hours` command: Captures hours (float), program (popup selector based on /enumerations/time_entry_activities.json) ans an options note.
66

77
## 2025-01-30
88

netbot/cog_tickets.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -859,12 +859,11 @@ async def help(self, ctx: discord.ApplicationContext):
859859
await ctx.respond(embed=self.bot.formatter.help_embed(ctx))
860860

861861

862-
@discord.slash_command(name="record_time", description="Record time against a program")
862+
@discord.slash_command(name="hours", description="Record time against a program")
863863
@option("hours", description="Hours worked on the program: `3.5`")
864864
@option("program_id", choices=get_program_options(), description="Select the program or grant", required=True)
865865
@option("note", description="Optional: Additional comments")
866866
async def recordTime(self, ctx: discord.ApplicationContext, hours: float, program_id: int, note: str = ""):
867-
log.info(f">>> {hours} {program_id} {note}")
868867
redmine: Client = ctx.bot.redmine
869868

870869
user = redmine.user_mgr.find(ctx.user.name)
@@ -884,5 +883,5 @@ async def recordTime(self, ctx: discord.ApplicationContext, hours: float, progra
884883
redmine.ticket_mgr.record_time(ticket_id, user, hours, program_id, note)
885884
if autoresolve:
886885
redmine.ticket_mgr.resolve(ticket_id)
887-
888-
await ctx.respond(f"Recorded {hours} on {program_id} for {user.discord}")
886+
program = ctx.bot.redmine.ticket_mgr.get_program_by_id(program_id)
887+
await ctx.respond(f"Recorded **{hours} hours** on **{program}** for *{user.discord}*")

redmine/tickets.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ def get_program(self, program_name: str) -> int:
103103
return self.programs.get(program_name, self.default_program)
104104

105105

106+
def get_program_by_id(self, program_id) -> str:
107+
for name, prog_id in self.programs.items():
108+
if program_id == prog_id:
109+
return name
110+
111+
106112
def load_priorities(self) -> dict[str,NamedId]:
107113
"""load active priorities"""
108114

uv.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)