Compare commits

..

2 commits

Author SHA1 Message Date
f287806bcd Remove smalltext from non-bots
I don't like it.
2026-02-03 01:23:12 +13:00
45285a4835 Only send components if they rendered to something 2026-02-03 01:22:38 +13:00
3 changed files with 29 additions and 17 deletions

View file

@ -474,6 +474,12 @@ async function messageToEvent(message, guild, options = {}, di) {
content = transformAttachmentLinks(content) content = transformAttachmentLinks(content)
content = await transformContentMessageLinks(content) content = await transformContentMessageLinks(content)
// Remove smalltext from non-bots (I don't like it). Webhooks included due to PluralKit.
const isHumanOrDataMissing = !message.author?.bot
if (isHumanOrDataMissing || dUtils.isWebhookMessage(message)) {
content = content.replaceAll(/^-# +([^\n].*?)/gm, "...$1")
}
// 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. // 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. // So we scan the message ahead of time for all its emojis and ensure they are in the DB.
const emojiMatches = [...content.matchAll(/<(a?):([^:>]{1,64}):([0-9]+)>/g)] const emojiMatches = [...content.matchAll(/<(a?):([^:>]{1,64}):([0-9]+)>/g)]
@ -850,7 +856,9 @@ async function messageToEvent(message, guild, options = {}, di) {
} }
const {body, formatted_body} = stack[0].get() const {body, formatted_body} = stack[0].get()
await addTextEvent(body, formatted_body, "m.text") if (body.trim().length) {
await addTextEvent(body, formatted_body, "m.text")
}
} }
// Then polls // Then polls

View file

@ -1605,3 +1605,18 @@ test("message2event: multiple-choice poll", async t => {
"org.matrix.msc1767.text": "more than one answer allowed\n1. [😭] no\n2. oh no\n3. oh noooooo" "org.matrix.msc1767.text": "more than one answer allowed\n1. [😭] no\n2. oh no\n3. oh noooooo"
}]) }])
}) })
test("message2event: smalltext from regular user", async t => {
const events = await messageToEvent({
content: "-# hmm",
author: {
bot: false
}
})
t.deepEqual(events, [{
$type: "m.room.message",
msgtype: "m.text",
"m.mentions": {},
body: "...hmm"
}])
})

View file

@ -4987,31 +4987,20 @@ module.exports = {
edited_timestamp: null, edited_timestamp: null,
flags: 32768, flags: 32768,
author: { author: {
id: '772659086046658620', id: '466378653216014359',
username: 'cadence.worm', username: 'PluralKit',
avatar: '466df0c98b1af1e1388f595b4c1ad1b9', avatar: '466df0c98b1af1e1388f595b4c1ad1b9',
discriminator: '0', discriminator: '0',
public_flags: 0, public_flags: 0,
flags: 0, flags: 0,
bot: true,
banner: null, banner: null,
accent_color: null, accent_color: null,
global_name: 'cadence', global_name: 'PluralKit',
avatar_decoration_data: null, avatar_decoration_data: null,
collectibles: null, collectibles: null,
display_name_styles: null, display_name_styles: null,
banner_color: null, banner_color: null
clan: {
identity_guild_id: '532245108070809601',
identity_enabled: true,
tag: 'doll',
badge: 'dba08126b4e810a0e096cc7cd5bc37f0'
},
primary_guild: {
identity_guild_id: '532245108070809601',
identity_enabled: true,
tag: 'doll',
badge: 'dba08126b4e810a0e096cc7cd5bc37f0'
}
}, },
components: [ components: [
{ {