Makes the server notify the same users the chat highlights and the editor suggests, by defining once what counts as an @mention.

Functions

f
mentionedUsernames(body: string): string[]

Returns the names body mentions, in lower case, each once. Code, fenced or inline, and URLs mention no one, as Markdown shows them. The server notifies by it, and the chat highlights and chimes by it.

f
mentionsEveryone(body: string): boolean

Checks whether body says @everyone, in any case, by the rule of mentionedUsernames. Only the chat service reads it, to set a message's mentionsEveryone when its author may; the client reads that flag, not the text.

Variables

v
EVERYONE: "everyone"

The name @everyone reaches. Said by a role with chat:everyone in the chat, it notifies every user, so no account may take it (assertUsernameAvailable).

v
MENTION_RE: RegExp

Matches an @handle, a local @name or a remote user's @name@host (HANDLE_SOURCE), with the handle as its first group. The @ must not follow a word character, so an email address mentions no one. Nor may it follow [ or (, which leaves out a Markdown link's text or URL starting with @, and also a plain (@name). The editor's suggestions match its source at the caret; the rest goes through mentionedUsernames. Markdown links mentions with a looser pattern of its own, on text already parsed, where code and URLs are out of the way.