mirror of
https://git.sr.ht/~emerson/reflectionircd
synced 2025-04-13 09:59:52 +00:00
add sticker support
This commit is contained in:
parent
43ea4a2a54
commit
7cdba2c276
3 changed files with 24 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
|||
### Added
|
||||
- `AWAY` and `away-notify`
|
||||
- Typing notifications
|
||||
- Sticker support (M->I only)
|
||||
|
||||
## v0.1.1 - 2022-02-09
|
||||
- Fix `DELETEMSG` being sent to unsupporting clients
|
||||
|
|
|
@ -79,7 +79,7 @@ On Libera I'm `emerson`, on Matrix I'm `@emersonveenstra:matrix.org`, feel free
|
|||
| Name | M->I | I->M | Notes |
|
||||
| ---- | :--: | :--: | ----- |
|
||||
| text, notice, emote messages | ✅ | ✅ ||
|
||||
| image, file, audio, video messages | 🟨 | ❌ | Show up as links on IRC |
|
||||
| image, sticker, file, audio, video messages | 🟨 | ❌ | Show up as links on IRC |
|
||||
| Channel joins | ✅ | ❌ | [#1](https://todo.sr.ht/~emerson/reflectionircd/1) |
|
||||
| Channel parts | ✅ | ✅ ||
|
||||
| Channel kicks | ✅ | ✅ ||
|
||||
|
|
|
@ -251,6 +251,9 @@ export class Server {
|
|||
case 'm.room.topic':
|
||||
this.handleMatrixTopic(nextEvent, targetChannel);
|
||||
break;
|
||||
case 'm.sticker':
|
||||
this.handleMatrixSticker(nextEvent, targetChannel);
|
||||
break;
|
||||
case 'm.typing':
|
||||
this.handleMatrixTyping(nextEvent, targetChannel);
|
||||
break;
|
||||
|
@ -590,6 +593,25 @@ export class Server {
|
|||
});
|
||||
}
|
||||
|
||||
handleMatrixSticker(event: any, targetChannel: Channel) {
|
||||
const sourceUser = this.getOrCreateMatrixUser(event["sender"]);
|
||||
this.checkForLazyJoin(event, sourceUser, targetChannel);
|
||||
const altText = event["content"]?.["body"];
|
||||
const imgMxc = event["content"]?.["url"];
|
||||
if (!altText || !imgMxc) {
|
||||
return;
|
||||
}
|
||||
const mxcregex = imgMxc.match(/mxc:\/\/(?<servername>[^\/]+)\/(?<mediaid>.+)/)
|
||||
let uri = imgMxc;
|
||||
if (!mxcregex || !mxcregex.groups) {
|
||||
console.log(`Failed to parse MXC URI: ${imgMxc}`);
|
||||
} else {
|
||||
uri = `${this.homeserver}/_matrix/media/v3/download/${mxcregex.groups.servername}/${mxcregex.groups.mediaid}`;
|
||||
}
|
||||
const messageContent = `\x01ACTION sent a sticker: ${altText}: ${uri}\x01`;
|
||||
this.sendToAll(sourceUser.getMask(), 'PRIVMSG', [targetChannel.name, messageContent]);
|
||||
}
|
||||
|
||||
handleMatrixTyping(event: any, targetChannel: Channel) {
|
||||
const typingUsers = event["content"]?.["user_ids"];
|
||||
if (!typingUsers) {
|
||||
|
|
Loading…
Add table
Reference in a new issue