feat: support custom CTCP VERSION responses

This commit is contained in:
Zach Bloomquist 2023-09-10 20:43:51 -04:00
parent 9f05a75c39
commit 02e735aa25
3 changed files with 20 additions and 1 deletions

View file

@ -218,6 +218,19 @@ module.exports = {
// default.
leaveMessage: "The Lounge - https://thelounge.chat",
// ### `versionResponse`
//
// A template string to format thelounge's response to CTCP VERSION requests. The
// tokens `%product-name%`, `%version%`, and `%url%` will be replaced by the
// appropriate values for the currently running version of The Lounge.
//
// You can use this to remove version information from the CTCP VERSION response
// for hardening.
//
// The default template string results in a response of
// `thelounge vX.Y.Z -- https://thelounge.chat`.
versionResponse: "%product-name% %version% -- %url%",
// ## Default network
// ### `defaults`

View file

@ -94,6 +94,7 @@ export type ConfigType = {
fileUpload: FileUpload;
transports: string[];
leaveMessage: string;
versionResponse: string;
defaults: Defaults;
lockNetwork: boolean;
messageStorage: string[];

View file

@ -1,4 +1,5 @@
import _ from "lodash";
import Config from "../../config";
import {IrcEventHandler} from "../../client";
import Helper from "../../helper";
import Msg, {MessageType} from "../../models/msg";
@ -12,7 +13,11 @@ const ctcpResponses = {
.join(" "),
PING: ({message}: {message: string}) => message.substring(5),
SOURCE: () => pkg.repository.url,
VERSION: () => pkg.name + " " + Helper.getVersion() + " -- " + pkg.homepage,
VERSION: () =>
Config.values.versionResponse
.replace("%product-name%", pkg.name)
.replace("%version%", Helper.getVersion())
.replace("%url%", pkg.homepage),
};
export default <IrcEventHandler>function (irc, network) {