Compare commits
No commits in common. "67fd5ff01640eda350cfbd13ccc00063fd4775c9" and "cfa1856118e6274020ec258eea59e4da311578f1" have entirely different histories.
67fd5ff016
...
cfa1856118
5 changed files with 9 additions and 12 deletions
|
@ -131,8 +131,8 @@ async function messageToEvent(message, guild, options = {}, di) {
|
||||||
escapeHTML: false,
|
escapeHTML: false,
|
||||||
}, null, null)
|
}, null, null)
|
||||||
|
|
||||||
// Mentions scenario 3: scan the message content for written @mentions of matrix users. Allows for up to one space between @ and mention.
|
// Mentions scenario 3: scan the message content for written @mentions of matrix users
|
||||||
const matches = [...content.matchAll(/@ ?([a-z0-9._]+)\b/gi)]
|
const matches = [...content.matchAll(/@([a-z0-9._]+)\b/gi)]
|
||||||
if (matches.length && matches.some(m => m[1].match(/[a-z]/i))) {
|
if (matches.length && matches.some(m => m[1].match(/[a-z]/i))) {
|
||||||
const writtenMentionsText = matches.map(m => m[1].toLowerCase())
|
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)
|
const roomID = db.prepare("SELECT room_id FROM channel_room WHERE channel_id = ?").pluck().get(message.channel_id)
|
||||||
|
|
|
@ -247,12 +247,10 @@ test("message2event: simple reply to matrix user, reply fallbacks disabled", asy
|
||||||
}])
|
}])
|
||||||
})
|
})
|
||||||
|
|
||||||
test("message2event: simple written @mentions for matrix users", async t => {
|
test("message2event: simple written @mention for matrix user", async t => {
|
||||||
let called = 0
|
|
||||||
const events = await messageToEvent(data.message.simple_written_at_mention_for_matrix, data.guild.general, {}, {
|
const events = await messageToEvent(data.message.simple_written_at_mention_for_matrix, data.guild.general, {}, {
|
||||||
api: {
|
api: {
|
||||||
async getJoinedMembers(roomID) {
|
async getJoinedMembers(roomID) {
|
||||||
called++
|
|
||||||
t.equal(roomID, "!kLRqKKUQXcibIMtOpl:cadence.moe")
|
t.equal(roomID, "!kLRqKKUQXcibIMtOpl:cadence.moe")
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -292,7 +290,6 @@ test("message2event: simple written @mentions for matrix users", async t => {
|
||||||
msgtype: "m.text",
|
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"
|
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 => {
|
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": {
|
"dependencies": {
|
||||||
"better-sqlite3": "^8.3.0",
|
"better-sqlite3": "^8.3.0",
|
||||||
"cloudstorm": "^0.8.0",
|
"cloudstorm": "^0.8.0",
|
||||||
"discord-markdown": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#9799e4f79912d07f89a030e479e82fcc1e75bc81",
|
"discord-markdown": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#df495b152fdc48fb22284ecda9a988e6df61bf99",
|
||||||
"heatsync": "^2.4.1",
|
"heatsync": "^2.4.1",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"matrix-appservice": "^2.0.0",
|
"matrix-appservice": "^2.0.0",
|
||||||
|
@ -351,9 +351,9 @@
|
||||||
"integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w=="
|
"integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w=="
|
||||||
},
|
},
|
||||||
"node_modules/@types/react": {
|
"node_modules/@types/react": {
|
||||||
"version": "18.2.20",
|
"version": "18.2.6",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.20.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.6.tgz",
|
||||||
"integrity": "sha512-WKNtmsLWJM/3D5mG4U84cysVY31ivmyw85dE84fOCk5Hx78wezB/XEjVPWl2JTZ5FkEeaTJf+VgUAUn3PE7Isw==",
|
"integrity": "sha512-wRZClXn//zxCFW+ye/D2qY65UsYP1Fpex2YXorHc8awoNamkMZSvBxwxdYVInsHOZZd2Ppq8isnSzJL5Mpf8OA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/prop-types": "*",
|
"@types/prop-types": "*",
|
||||||
"@types/scheduler": "*",
|
"@types/scheduler": "*",
|
||||||
|
@ -1051,7 +1051,7 @@
|
||||||
},
|
},
|
||||||
"node_modules/discord-markdown": {
|
"node_modules/discord-markdown": {
|
||||||
"version": "2.4.1",
|
"version": "2.4.1",
|
||||||
"resolved": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#9799e4f79912d07f89a030e479e82fcc1e75bc81",
|
"resolved": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#df495b152fdc48fb22284ecda9a988e6df61bf99",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"simple-markdown": "^0.7.2"
|
"simple-markdown": "^0.7.2"
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"better-sqlite3": "^8.3.0",
|
"better-sqlite3": "^8.3.0",
|
||||||
"cloudstorm": "^0.8.0",
|
"cloudstorm": "^0.8.0",
|
||||||
"discord-markdown": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#9799e4f79912d07f89a030e479e82fcc1e75bc81",
|
"discord-markdown": "git+https://git.sr.ht/~cadence/nodejs-discord-markdown#df495b152fdc48fb22284ecda9a988e6df61bf99",
|
||||||
"heatsync": "^2.4.1",
|
"heatsync": "^2.4.1",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"matrix-appservice": "^2.0.0",
|
"matrix-appservice": "^2.0.0",
|
||||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue