support up to 1 space in written mentions

This commit is contained in:
Cadence Ember 2023-08-17 18:17:53 +12:00
commit e00eb15f35
3 changed files with 6 additions and 3 deletions

View file

@ -131,8 +131,8 @@ async function messageToEvent(message, guild, options = {}, di) {
escapeHTML: false,
}, null, null)
// Mentions scenario 3: scan the message content for written @mentions of matrix users
const matches = [...content.matchAll(/@([a-z0-9._]+)\b/gi)]
// Mentions scenario 3: scan the message content for written @mentions of matrix users. Allows for up to one space between @ and mention.
const matches = [...content.matchAll(/@ ?([a-z0-9._]+)\b/gi)]
if (matches.length && matches.some(m => m[1].match(/[a-z]/i))) {
const writtenMentionsText = matches.map(m => m[1].toLowerCase())
const roomID = db.prepare("SELECT room_id FROM channel_room WHERE channel_id = ?").pluck().get(message.channel_id)