diff --git a/config.sample.yaml b/config.sample.yaml index 14c23fdd3..d95bfbca4 100644 --- a/config.sample.yaml +++ b/config.sample.yaml @@ -602,6 +602,8 @@ ircService: shortReplyTemplate: "$NICK: $REPLY" # format of replies sent a while after the original message longReplyTemplate: "$NICK: \"$ORIGINAL\" <- $REPLY" + # format of replies where the sender of the original message is the same as the sender of the reply + selfReplyTemplate: "<$NICK> $ORIGINAL\n$REPLY" # how much time needs to pass between the reply and the original message to switch to the long format shortReplyTresholdSeconds: 300 # Ignore users mentioned in a io.element.functional_members state event when checking admin room membership diff --git a/config.schema.yml b/config.schema.yml index 17d78fe2a..6bedeaf03 100644 --- a/config.schema.yml +++ b/config.schema.yml @@ -171,6 +171,8 @@ properties: type: "string" shortReplyTresholdSeconds: type: "integer" + selfReplyTemplate: + type: "string" ignoreFunctionalMembersInAdminRooms: type: "boolean" ircHandler: diff --git a/src/bridge/MatrixHandler.ts b/src/bridge/MatrixHandler.ts index 22b8e2969..b68e34cea 100644 --- a/src/bridge/MatrixHandler.ts +++ b/src/bridge/MatrixHandler.ts @@ -55,6 +55,8 @@ export interface MatrixHandlerConfig { shortReplyTemplate: string; // Format of replies sent a while after the original message longReplyTemplate: string; + // format of replies where the sender of the original message is the same as the sender of the reply + selfReplyTemplate: string; // Format of the text explaining why a message is truncated and pastebinned truncatedMessageTemplate: string; // Ignore io.element.functional_members members joining admin rooms. @@ -68,6 +70,7 @@ export const DEFAULTS: MatrixHandlerConfig = { shortReplyTresholdSeconds: 5 * 60, shortReplyTemplate: "$NICK: $REPLY", longReplyTemplate: "$NICK: \"$ORIGINAL\" <- $REPLY", + selfReplyTemplate: "<$NICK> $ORIGINAL\n$REPLY", truncatedMessageTemplate: "(full message at <$URL>)", ignoreFunctionalMembersInAdminRooms: false, }; @@ -1469,10 +1472,19 @@ export class MatrixHandler { let replyTemplate: string; const thresholdMs = (this.config.shortReplyTresholdSeconds) * 1000; if (rplSource && event.origin_server_ts - cachedEvent.timestamp > thresholdMs) { - replyTemplate = this.config.longReplyTemplate; + if (cachedEvent.sender === event.sender) { + // They're replying to their own message. + replyTemplate = this.config.selfReplyTemplate; + } + else { + replyTemplate = this.config.longReplyTemplate; + } } else { - replyTemplate = this.config.shortReplyTemplate; + if (cachedEvent.sender !== event.sender) { + // Someone[m] pinging themself is weird + replyTemplate = this.config.shortReplyTemplate; + } } const formattedReply = renderTemplate(replyTemplate, {