Skip to content
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
2 changes: 1 addition & 1 deletion csp_bot/backends/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class DiscordAdapterConfig(BaseModel):
class DiscordMessage(Struct):
_ignore: str = ""

mention_user_discord = lambda x: x # noqa: E731
mention_user_discord = None
2 changes: 1 addition & 1 deletion csp_bot/backends/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class SlackAdapterConfig(BaseModel):
class SlackMessage(Struct):
_ignore: str = ""

mention_user_slack = lambda x: x # noqa: E731
mention_user_slack = None
2 changes: 1 addition & 1 deletion csp_bot/backends/symphony.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ class SymphonyAdapterConfig(BaseModel):
class SymphonyMessage(Struct):
_ignore: str = ""

mention_user_symphony = lambda x: x # noqa: E731
mention_user_symphony = None
6 changes: 6 additions & 0 deletions csp_bot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,18 @@ def recursive_format_for_message_ml(d):

def mention_user(email_or_userid: str = "", backend: Backend = "symphony") -> str:
if backend == "symphony":
if mention_user_symphony is None:
raise ImportError("Symphony adapter is not available.")
return mention_user_symphony(email_or_userid)
elif backend == "slack":
if not email_or_userid.startswith("@"):
email_or_userid = f"@{email_or_userid}"
if mention_user_slack is None:
raise ImportError("Slack adapter is not available.")
return mention_user_slack(email_or_userid)
elif backend == "discord":
if mention_user_discord is None:
raise ImportError("Discord adapter is not available.")
return mention_user_discord(email_or_userid)
else:
raise NotImplementedError(f"Unsupported backend: {backend}")
Loading