Skip to content

Commit

Permalink
[Halpy-361] Combine Cases Command First Pass
Browse files Browse the repository at this point in the history
- Adds a new command, ``combcases``, and adds a corresponding help text.
  • Loading branch information
C1701D committed May 12, 2024
1 parent 60b567d commit 56e8d22
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions data/help/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@
"arguments": "[Board ID] [New Dispatchers]",
"use": "Add a new dispatcher to a given case on the board."
},
"combcases": {
"aliases:": [],
"arguments": "[Board ID to keep] [Board ID to combine]",
"use": "Combine two cases into a single case."
},
"delcase": {
"aliases:": [
"remcase"
Expand Down
30 changes: 30 additions & 0 deletions halpybot/commands/caseutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,36 @@ async def cmd_editnote(ctx: Context, args: List[str], case: Case):


# ADMINSTRATIVE MANAGEMENT
@Commands.command("combcases")
@needs_permission(Admin)
@in_channel
@gather_case(2)
async def cmd_combine_cases(ctx: Context, args: List[str], case: Case):
"""
Combines two cases into one, transferring all notes and responders from the second case to the first.
Usage: !combcases [board ID to keep] [board ID to combine]
Aliases: n/a
"""
try:
case2: Case = await get_case(ctx, args[1])
except KeyError:
return await ctx.reply(f"No case found for {args[1]!r}.")
# case.case_notes.extend(case2.case_notes)
case.responders.extend(case2.responders)
case.dispatchers.extend(case2.dispatchers)
if case2.welcomed:
res_kwarg = {"welcomed": True}
await ctx.bot.board.mod_case(case_id=case.board_id, **res_kwarg)
case_comb_note = f"{ctx.sender} combined case {case2.board_id} into case {case.board_id} at {now(tz='UTC').to_time_string()}"
case_summary = f"{case2}"
case.case_notes.append(case_comb_note)
case.case_notes.append(case_summary)

await ctx.bot.board.del_case(case=case2)
return await ctx.reply(f"Combined case {case2.board_id} into case {case.board_id}.")


@Commands.command("delcase", "remcase")
@needs_permission(Admin)
@in_channel
Expand Down

0 comments on commit 56e8d22

Please sign in to comment.