Skip to content

Commit

Permalink
Merge pull request #365 from HullSeals/enhancement/silent-welcome
Browse files Browse the repository at this point in the history
[Enhancement] Add Silent Welcome Option
  • Loading branch information
Rixxan authored May 21, 2024
2 parents 21faaa7 + 837cb35 commit a6ee308
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 16 deletions.
7 changes: 6 additions & 1 deletion data/help/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"use": "Print out the current cases on the Board."
},
"listcase": {
"aliases:": [],
"aliases:": ["caseinfo"],
"arguments": "[Board ID]",
"use": "List specific details of a current case."
},
Expand Down Expand Up @@ -170,6 +170,11 @@
"arguments": "[Client Name or Board ID]",
"use": "Welcome a client and add an identified Seal as a Dispatch responder."
},
"silentwelcome": {
"aliases:": ["swelcome", "wmute", "mute"],
"arguments": "[Client Name or Board ID]",
"use": "Suppress the welcome warning and add an identified Seal as a Dispatch responder."
},
"addresp": {
"aliases:": [
"newseal"
Expand Down
52 changes: 38 additions & 14 deletions halpybot/commands/caseutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,8 @@ async def cmd_go(ctx: Context, args: List[str], case: Case):
)


@Commands.command("welcome")
@needs_permission(Pup)
async def cmd_welcome(ctx: Context, args: List[str]):
"""
Welcome the Client and add an identified Seal as a Dispatch responder.
Usage: !welcome [Case ID]
Aliases: n/a
"""
async def welcome_utils(ctx: Context, args: List[str]):
"""Utilities for welcome messages"""
case = None
try:
case: Optional[Case] = await get_case(ctx, args[0])
Expand All @@ -138,10 +131,7 @@ async def cmd_welcome(ctx: Context, args: List[str]):
case = test_case
break
if not case:
await ctx.reply(
await ctx.bot.facts.fact_formatted(fact=("welcome", "en"), arguments=args)
)
return await ctx.reply(f"Attn {ctx.sender}: Case for {args[0]} not found!")
return None
spatches = case.dispatchers
try:
spatch: Seal = await whois(ctx.bot.engine, ctx.sender)
Expand All @@ -154,12 +144,46 @@ async def cmd_welcome(ctx: Context, args: List[str]):
spatches.append(spatch)
res_kwarg = {"welcomed": True, "dispatchers": spatches}
await ctx.bot.board.mod_case(case_id=case.board_id, **res_kwarg)
return case


@Commands.command("welcome")
@needs_permission(Pup)
async def cmd_welcome(ctx: Context, args: List[str]):
"""
Welcome the Client and add an identified Seal as a Dispatch responder.
Usage: !welcome [Case ID]
Aliases: n/a
"""
case = await welcome_utils(ctx, args)
if not case:
await ctx.reply(
await ctx.bot.facts.fact_formatted(fact=("welcome", "en"), arguments=args)
)
return await ctx.reply(f"Attn {ctx.sender}: Case for {args[0]} not found!")
args = [case.irc_nick]
return await ctx.reply(
await ctx.bot.facts.fact_formatted(fact=("welcome", "en"), arguments=args)
)


@Commands.command("silentwelcome", "swelcome", "wmute", "mute")
@needs_permission(Pup)
async def cmd_welcome(ctx: Context, args: List[str]):
"""
Suppress the welcome warning and add an identified Seal as a Dispatch responder.
Usage: !silentwelcome [Case ID]
Aliases: n/a
"""
case = await welcome_utils(ctx, args)
if not case:
return await ctx.reply(f"Attn {ctx.sender}: Case for {args[0]} not found!")

return await ctx.reply(f"Suppressed welcome warning for {case.irc_nick}")


# RESPONDER MANAGEMENT:
@Commands.command("addresp", "newseal")
@needs_permission(Drilled)
Expand Down Expand Up @@ -268,7 +292,7 @@ async def cmd_listboard(ctx: Context, args: List[str]):
return await ctx.redirect(message)


@Commands.command("listcase")
@Commands.command("listcase", "caseinfo")
@needs_permission(Drilled)
@gather_case(1)
async def cmd_listcase(ctx: Context, args: List[str], case: Case):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tqdm = "^4.66.2"
attrs = "^23.2.0 "
cattrs = "^23.2.3 "
loguru = "^0.7.0"
pydantic = {extras = ["dotenv"], version = "^1.10.2"}
pydantic = {extras = ["dotenv"], version = "^1.10.5"}
sqlalchemy = "^2.0.29"
beautifulsoup4 = "^4.12.3"
lxml = "^5.2.1"
Expand Down

0 comments on commit a6ee308

Please sign in to comment.