Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Add Silent Welcome Option #365

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading