Utilities¶

Utility class for formatting Slack Messages.

utils.slack_msg_fmt.wrap_code_block(str)¶

Format code block.

utils.slack_msg_fmt.wrap_emph(str)¶

Format emph.

utils.slack_msg_fmt.wrap_quote(str)¶

Format quote.

utils.slack_msg_fmt.wrap_slack_code(str)¶

Format code.

The following are a few functions to help in handling command.

utils.slack_parse.check_permissions(user, team)¶

Check if given user is admin or team lead.

If team is specified and user is not admin, check if user is team lead in team. If team is not specified, check if user is team lead.

Parameters:
  • user (User) – user who’s permission needs to be checked
  • team (Optional[Team]) – team you want to check that has user as team lead
Return type:

bool

Returns:

true if user is admin or a team lead, false otherwise

utils.slack_parse.escape_email(email)¶

Convert a string with escaped emails to just the email.

Before:

<mailto:email@a.com|email@a.com>

After:

email@a.com
Parameters:email (str) – email to convert
Return type:str
Returns:unescaped email
utils.slack_parse.escaped_id_to_id(s)¶

Convert a string with escaped IDs to just the IDs.

Before:

/rocket user edit --member <@U1143214|su> --name "Steven Universe"

After:

/rocket user edit --member U1143214 --name "Steven Universe"
Parameters:s (str) – string to convert
Return type:str
Returns:string where all instances of escaped ID is replaced with IDs
utils.slack_parse.ios_dash(s)¶

Convert a string with a dash (—) to just double-hyphens (–).

Before:

/rocket user edit —name "Steven Universe"

After:

/rocket user edit --name "Steven Universe"
Parameters:s (str) – string to convert
Return type:str
Returns:string where all dashes are replaced with double-hyphens
utils.slack_parse.is_slack_id(id)¶

Check if id given is a valid slack id.

Parameters:id (str) – string of the object you want to check
Return type:bool
Returns:true if object is a slack id, false otherwise
utils.slack_parse.regularize_char(c)¶

Convert any unicode quotation marks to ascii ones.

Leaves all other characters alone.

Parameters:c (str) – character to convert
Return type:str
Returns:ascii equivalent (only quotes are changed)