From 02d221ff4c447725a335ad430fffaa806935d923 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Sat, 24 Sep 2022 12:20:31 +0300 Subject: [PATCH] ctcp wrapper function --- src/utility/message-formatting.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utility/message-formatting.ts b/src/utility/message-formatting.ts index b2f5d08..547391b 100644 --- a/src/utility/message-formatting.ts +++ b/src/utility/message-formatting.ts @@ -129,6 +129,15 @@ export const applyTextFormat = ( ? str : `${IRC_FMT_FORMAT_MAP[format]}${str}${IRC_FMT_RESET}`; +/** + * Apply CTCP control characters with a command. + * @param message Message + * @param command CTCP command, e.g. `ACTION` + * @returns Text with control characters + */ +export const applyCTCP = (message: string, command = 'ACTION') => + `\x01${command.toUpperCase()} ${message}\x01`; + const styleCheckRe = /[\x00-\x1F]/; const backRe = /^(\d{1,2})(,(\d{1,2}))?/; const colourKey = '\x03';