Compare commits
2 commits
cfa1856118
...
67fd5ff016
Author | SHA1 | Date | |
---|---|---|---|
67fd5ff016 | |||
036a9f6a04 |
5 changed files with 12 additions and 9 deletions
|
@ -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)
|
||||
|
|
|
@ -247,10 +247,12 @@ test("message2event: simple reply to matrix user, reply fallbacks disabled", asy
|
|||
}])
|
||||
})
|
||||
|
||||
test("message2event: simple written @mention for matrix user", async t => {
|
||||
test("message2event: simple written @mentions for matrix users", async t => {
|
||||
let called = 0
|
||||
const events = await messageToEvent(data.message.simple_written_at_mention_for_matrix, data.guild.general, {}, {
|
||||
api: {
|
||||
async getJoinedMembers(roomID) {
|
||||
called++
|
||||
t.equal(roomID, "!kLRqKKUQXcibIMtOpl:cadence.moe")
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
|
@ -290,6 +292,7 @@ test("message2event: simple written @mention for matrix user", async t => {
|
|||
msgtype: "m.text",
|
||||
body: "@Cadence, tell me about @Phil, the creator of the Chin Trick, who has become ever more powerful under the mentorship of @botrac4r and @huck"
|
||||
}])
|
||||
t.equal(called, 1, "should only look up the member list once")
|
||||
})
|
||||
|
||||
test("message2event: very large attachment is linked instead of being uploaded", async t => {
|
||||
|
|
10
package-lock.json
generated
10
package-lock.json
generated
|
@ -11,7 +11,7 @@
|
|||
"dependencies": {
|
||||
"better-sqlite3": "^8.3.0",
|
||||
"cloudstorm": "^0.8.0",
|
||||
"discord-markdown": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#df495b152fdc48fb22284ecda9a988e6df61bf99",
|
||||
"discord-markdown": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#9799e4f79912d07f89a030e479e82fcc1e75bc81",
|
||||
"heatsync": "^2.4.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"matrix-appservice": "^2.0.0",
|
||||
|
@ -351,9 +351,9 @@
|
|||
"integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w=="
|
||||
},
|
||||
"node_modules/@types/react": {
|
||||
"version": "18.2.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.6.tgz",
|
||||
"integrity": "sha512-wRZClXn//zxCFW+ye/D2qY65UsYP1Fpex2YXorHc8awoNamkMZSvBxwxdYVInsHOZZd2Ppq8isnSzJL5Mpf8OA==",
|
||||
"version": "18.2.20",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.20.tgz",
|
||||
"integrity": "sha512-WKNtmsLWJM/3D5mG4U84cysVY31ivmyw85dE84fOCk5Hx78wezB/XEjVPWl2JTZ5FkEeaTJf+VgUAUn3PE7Isw==",
|
||||
"dependencies": {
|
||||
"@types/prop-types": "*",
|
||||
"@types/scheduler": "*",
|
||||
|
@ -1051,7 +1051,7 @@
|
|||
},
|
||||
"node_modules/discord-markdown": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#df495b152fdc48fb22284ecda9a988e6df61bf99",
|
||||
"resolved": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#9799e4f79912d07f89a030e479e82fcc1e75bc81",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"simple-markdown": "^0.7.2"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
"dependencies": {
|
||||
"better-sqlite3": "^8.3.0",
|
||||
"cloudstorm": "^0.8.0",
|
||||
"discord-markdown": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#df495b152fdc48fb22284ecda9a988e6df61bf99",
|
||||
"discord-markdown": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#9799e4f79912d07f89a030e479e82fcc1e75bc81",
|
||||
"heatsync": "^2.4.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"matrix-appservice": "^2.0.0",
|
||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue