diff --git a/d2m/converters/message-to-event.js b/d2m/converters/message-to-event.js index 15eaf34..69d1619 100644 --- a/d2m/converters/message-to-event.js +++ b/d2m/converters/message-to-event.js @@ -158,7 +158,7 @@ async function messageToEvent(message, guild, options = {}, di) { // Handling emojis that we don't know about. The emoji has to be present in the DB for it to be picked up in the emoji markdown converter. // So we scan the message ahead of time for all its emojis and ensure they are in the DB. - const emojiMatches = [...content.matchAll(/<(a?):([^:>]{2,20}):([0-9]+)>/g)] + const emojiMatches = [...content.matchAll(/<(a?):([^:>]{2,64}):([0-9]+)>/g)] const emojiDownloads = [] for (const match of emojiMatches) { const id = match[3] diff --git a/d2m/converters/message-to-event.test.js b/d2m/converters/message-to-event.test.js index c09708d..34f376f 100644 --- a/d2m/converters/message-to-event.test.js +++ b/d2m/converters/message-to-event.test.js @@ -403,3 +403,18 @@ test("message2event: mid-message small bridged emoji", async t => { formatted_body: 'h is for :hippo:!' }]) }) + +test("message2event: emoji triple long name", async t => { + const events = await messageToEvent(data.message.emoji_triple_long_name, data.guild.general, {}) + t.deepEqual(events, [{ + $type: "m.room.message", + "m.mentions": {}, + msgtype: "m.text", + body: ":brillillillilliant_move::brillillillilliant_move::brillillillilliant_move:", + format: "org.matrix.custom.html", + formatted_body: + ':brillillillilliant_move:' + + ':brillillillilliant_move:' + + ':brillillillilliant_move:' + }]) +}) diff --git a/db/ooye-test-data.sql b/db/ooye-test-data.sql index 68c6d00..2a56381 100644 --- a/db/ooye-test-data.sql +++ b/db/ooye-test-data.sql @@ -74,12 +74,14 @@ INSERT INTO emoji (id, name, animated, mxc_url) VALUES ('230201364309868544', 'hippo', 0, 'mxc://cadence.moe/qWmbXeRspZRLPcjseyLmeyXC'), ('393635038903926784', 'hipposcope', 1, 'mxc://cadence.moe/WbYqNlACRuicynBfdnPYtmvc'), ('362741439211503616', 'bn_re', 0, 'mxc://cadence.moe/OIpqpfxTnHKokcsYqDusxkBT'), -('551636841284108289', 'ae_botrac4r', 0, 'mxc://cadence.moe/skqfuItqxNmBYekzmVKyoLzs'); +('551636841284108289', 'ae_botrac4r', 0, 'mxc://cadence.moe/skqfuItqxNmBYekzmVKyoLzs'), +('975572106295259148', 'brillillillilliant_move', 0, 'mxc://cadence.moe/scfRIDOGKWFDEBjVXocWYQHik'); INSERT INTO member_cache (room_id, mxid, displayname, avatar_url) VALUES ('!kLRqKKUQXcibIMtOpl:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', NULL), ('!BpMdOUkWWhFxmTrENV:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', 'malformed mxc'), ('!fGgIymcYWOqjbSRUdV:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', 'mxc://cadence.moe/azCAhThKTojXSZJRoWwZmhvU'), -('!PnyBKvUBOhjuCucEfk:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', 'mxc://cadence.moe/azCAhThKTojXSZJRoWwZmhvU'); +('!PnyBKvUBOhjuCucEfk:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', 'mxc://cadence.moe/azCAhThKTojXSZJRoWwZmhvU'), +('!maggESguZBqGBZtSnr:cadence.moe', '@cadence:cadence.moe', 'cadence [they]', 'mxc://cadence.moe/azCAhThKTojXSZJRoWwZmhvU'); COMMIT; diff --git a/test/data.js b/test/data.js index a0e59d3..8cfa717 100644 --- a/test/data.js +++ b/test/data.js @@ -1038,6 +1038,36 @@ module.exports = { flags: 0, components: [] }, + emoji_triple_long_name: { + id: "1156394116540805170", + type: 0, + content: "<:brillillillilliant_move:975572106295259148><:brillillillilliant_move:975572106295259148><:brillillillilliant_move:975572106295259148>", + channel_id: "112760669178241024", + author: { + id: "111604486476181504", + username: "kyuugryphon", + avatar: "e4ce31267ca524d19be80e684d4cafa1", + discriminator: "0", + public_flags: 0, + flags: 0, + banner: null, + accent_color: null, + global_name: "KyuuGryphon", + avatar_decoration_data: null, + banner_color: null + }, + attachments: [], + embeds: [], + mentions: [], + mention_roles: [], + pinned: false, + mention_everyone: false, + tts: false, + timestamp: "2023-09-27T00:57:22.147000+00:00", + edited_timestamp: null, + flags: 0, + components: [] + } }, message_with_embeds: { nothing_but_a_field: {