From 162ba30f2cbd7f1893b8ecd57e6fc9dcfddeb59d Mon Sep 17 00:00:00 2001 From: NightStrang6r Date: Thu, 2 Feb 2023 17:56:13 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=82=EF=B8=8F=20Added=20replaceAll=20func?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/storage.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/storage.js b/src/storage.js index 596fc17..df8f527 100644 --- a/src/storage.js +++ b/src/storage.js @@ -143,7 +143,7 @@ function loadConfig() { autoIssue: Number(config.get('FunPay', 'autoDelivery')), autoResponse: Number(config.get('FunPay', 'autoResponse')), greetingMessage: Number(config.get('FunPay', 'greetingMessage')), - greetingMessageText: config.get('FunPay', 'greetingMessageText').replace('\\n', '\n'), + greetingMessageText: replaceAll(config.get('FunPay', 'greetingMessageText'), '\\n', '\n'), autoIssueTestCommand: Number(config.get('FunPay', 'autoDeliveryTestCommand')), watermark: config.get('FunPay', 'waterMark'), telegramBot: Number(config.get('Telegram', 'enabled')), @@ -289,6 +289,10 @@ async function loadAutoIssueFile() { return await fs.readFile(`${_dirname}/data/configs/delivery.json`, 'utf8'); } +function replaceAll(string, find, replace) { + return string.replace(new RegExp(find, 'g'), replace); +} + async function askSettings() { const question1 = await inq.prompt([{ name: 'golden_key', @@ -453,7 +457,7 @@ async function askSettings() { lotsRaiseNotification: (question5.lotsRaiseNotification == 'Да') ? 1 : 0, deliveryNotification: (question5.deliveryNotification == 'Да') ? 1 : 0, greetingMessage: (answers.greetingMessage == 'Да') ? 1 : 0, - greetingMessageText: 'Привет! Продавец скоро ответит на твоё сообщение.' + greetingMessageText: 'Привет, {name}!\nПродавец скоро ответит на твоё сообщение.' } console.log();