Skip to content

Commit

Permalink
irc: BridgedClient.ts: replace newlines with pipes "|"
Browse files Browse the repository at this point in the history
This is done to match IRC conventions. With this commit, topics such as:

        Welcome!
        Please don't ask to ask

Will get bridged as

        Welcome! | Please don't ask to ask

Signed-off-by: Ferass El Hafidi <[email protected]>
  • Loading branch information
Ferass El Hafidi authored and tadzik committed Feb 25, 2025
1 parent 062f3ac commit 74f02c8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/irc/BridgedClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -909,13 +909,17 @@ export class BridgedClient extends EventEmitter {
}

private async setTopic(room: IrcRoom, topic: string): Promise<void> {
// replace newline "\n" with a pipe "|" to follow IRC conventions
const sanitized_topic = topic.replace(/\n/g, " | ").replace(/\r/g, "")

if (this.state.status !== BridgedClientStatus.CONNECTED) {
throw Error("unsafeClient not ready yet");
}
// join the room if we haven't already
await this.joinChannel(room.channel);
this.log.info("Setting topic to %s in channel %s", topic, room.channel);
return this.state.client.send("TOPIC", room.channel, topic);

this.log.info("Setting topic to %s in channel %s", sanitized_topic, room.channel);
return this.state.client.send("TOPIC", room.channel, sanitized_topic);
}

private async sendMessage(room: IrcRoom, msgType: string, text: string, expiryTs: number) {
Expand Down

0 comments on commit 74f02c8

Please sign in to comment.