diff --git a/README.md b/README.md index 9e4ce8b..0aed098 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ That said, it is usable for basic chatting. | Name | M->I | I->M | Notes | | ---- | :--: | :--: | ----- | | text, notice, emote messages | ✅ | ✅ || -| image, file, audio, video messages | 🟨 | ❌ | Show up as MXC links on IRC | +| image, file, audio, video messages | 🟨 | ❌ | Show up as links on IRC | | Channel joins | ❌ | ❌ || | Channel parts | ❌ | ❌ || | Channel kicks | ❌ | ❌ || diff --git a/src/Channel.ts b/src/Channel.ts index 1123953..d9e86b7 100644 --- a/src/Channel.ts +++ b/src/Channel.ts @@ -152,9 +152,6 @@ export class Channel { } joinMatrixUser(matrixUser: MatrixUser, event: any) { - // During initial sync, all past/present members are returned, so we filter out non-joined members - if (event["content"]["membership"] !== "join" && !this.matrixUsers.has(matrixUser.nick)) - return; this.matrixUsers.set(matrixUser.nick, matrixUser); const prefix = matrixUser.getMask(); if (event) { @@ -168,6 +165,9 @@ export class Channel { handleMatrixMember(event: any) { const thisMatrixUser = this.server.getOrCreateMatrixUser(event["sender"]); + // During initial sync, all past/present members are returned, so we filter out non-joined members + if (event["content"]["membership"] !== "join" && !this.matrixUsers.has(thisMatrixUser.nick)) + return; this.matrixUsers.set(thisMatrixUser.nick, thisMatrixUser); } @@ -225,4 +225,27 @@ export class Channel { this.topic.set("text", event["content"]["topic"]); this.topic.set("timestamp", event["origin_server_ts"].toString()) } + + handleMatrixJoinRule(event: any) { + const rule = event["content"]?.["join_rule"]; + if (!rule) { + console.log(`Warning: join rule not found in ${event}`); + return; + } + if (rule === "public") { + if (this.modes.has('i')) { + this.modes.delete('i'); + this.ircUsers.forEach((user) => { + user.sendToAll(this.server.name, 'MODE', [this.name, '-i'], new Map()); + }); + } + } else { + if (!this.modes.has('i')) { + this.modes.set('i', ''); + this.ircUsers.forEach((user) => { + user.sendToAll(this.server.name, 'MODE', [this.name, '+i'], new Map()); + }); + } + } + } } \ No newline at end of file