message: Match all, and match it once
diff: @@ -37,12 +37,13 @@ MatrixAction.prototype.formatMentions = function(nickUserIdMap) {
  Object.keys(nickUserIdMap).map((value) => escapeStringRegexp(value)).join("|")
  + ")";
  const userRegex = new RegExp(regexString, "igm");
  + const matched = new Set();
  let match;
  let i = 0;
  while ((match = userRegex.exec(this.text)) !== null && i < MAX_MATCHES) {
  i++;
  let matchName = match[1];
  - if (matchName.length < MIN_LENGTH_TO_MATCH) {
  + if (matchName.length < MIN_LENGTH_TO_MATCH || matched.has(matchName.toLowerCase())) {
  continue;
  }
  log.debug(`Matched ${matchName} in ${this.text}`);
  @@ -62,9 +63,10 @@ MatrixAction.prototype.formatMentions = function(nickUserIdMap) {
  this.htmlText = this.text;
  }
  this.htmlText = this.htmlText.replace(
  - matchName,
  + new RegExp(matchName, "igm"),
  `<a href="https://matrix.to/#/${userId}">${matchName}</a>`
  );
  + matched.add(matchName.toLowerCase());
  }
  }
  