mirror of
https://git.sr.ht/~emerson/reflectionircd
synced 2025-08-05 16:59:10 +00:00
Add ability to highlight matrix users
This commit is contained in:
parent
5f2add147c
commit
c30270f435
2 changed files with 17 additions and 3 deletions
|
@ -13,6 +13,12 @@ That said, it is usable for basic chatting. See the support matrix (pun intended
|
|||
- Built-in bouncer: Multiple IRC clients can be authenticated to a Matrix user
|
||||
- Multi-user: Log in to multiple Matrix users at the same time
|
||||
|
||||
## Notes for IRC users
|
||||
|
||||
There's a few things "different" from a standard IRC network:
|
||||
- You can't PM users like normal. Direct messages are notated by the `&` channel prefix. Once joining channels is implemented, you can join the `&` channel and it will auto-invite the user.
|
||||
- In order to highlight users, you need to prefix their nick with an `@`, so `@emerson: hi`. Reflection automatically expands this to the user's MXID, so even though it's annoying, it's needed to stop inadvertent highlights for now.
|
||||
|
||||
## FAQs
|
||||
|
||||
### Who is this for?
|
||||
|
@ -41,7 +47,7 @@ Note that there are no PMs, because Matrix doesn't differentiate between DMs and
|
|||
|
||||
| Name | M->I | I->M | Notes |
|
||||
| ---- | :--: | :--: | ----- |
|
||||
| text, notice, emote messages | ✅ | ✅ | Highlighting users with their IRC nick doesn't translate into highlighting their Matrix user [#23](https://todo.sr.ht/~emerson/reflectionircd/23) |
|
||||
| text, notice, emote messages | ✅ | ✅ ||
|
||||
| image, file, audio, video messages | 🟨 | ❌ | Show up as links on IRC |
|
||||
| Channel joins | ✅ | ❌ | [#1](https://todo.sr.ht/~emerson/reflectionircd/1) |
|
||||
| Channel parts | ✅ | ✅ ||
|
||||
|
|
|
@ -340,9 +340,17 @@ export class Client {
|
|||
msgtype = 'm.emote';
|
||||
msgbody = msgbody.replace(/\x01(ACTION\s)?/gi, '');
|
||||
}
|
||||
const roomId = targetChannel.roomId;
|
||||
const highlightFilteredMsg = msgbody.split(" ").map(w => {
|
||||
if (!w.startsWith('@')) return w;
|
||||
const endingCharMatch = w.match(/[,:]$/);
|
||||
const endingChar = (endingCharMatch) ? endingCharMatch[0] : "";
|
||||
const endingCharIndex = (endingCharMatch) ? endingCharMatch.index : 0;
|
||||
const nickToSearch = (endingCharIndex === 0) ? w.substring(1) : w.substring(1, endingCharIndex);
|
||||
const maybeHighlight = targetChannel.matrixUsers.get(nickToSearch);
|
||||
return (maybeHighlight) ? `${maybeHighlight.mxid}${endingChar}` : w;
|
||||
})
|
||||
const content = {
|
||||
"body": msgbody,
|
||||
"body": highlightFilteredMsg.join(" "),
|
||||
"msgtype": msgtype,
|
||||
"m.relates_to": {}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue