diff --git a/dist/index.js b/dist/index.js index 33f0730..7fd1388 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1729,7 +1729,12 @@ module.exports = invoke; /***/ }), /***/ 690: -/***/ ((module) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +const { + restoreEscapedNewLine, + restoreEscapedTab, +} = __nccwpck_require__(307); const buildMessage = (channel = "", text = "", optional = {}) => { const message = { @@ -1747,11 +1752,6 @@ const buildMessage = (channel = "", text = "", optional = {}) => { return message; }; -const restoreEscapedNewLine = (text) => - text.replace(/\\r\\n/g, "\n").replace(/\\n/g, "\n"); - -const restoreEscapedTab = (text) => text.replace(/\\t/g, "\t"); - module.exports = buildMessage; @@ -1874,19 +1874,31 @@ module.exports = { addReaction }; /***/ }), /***/ 51: -/***/ ((module) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { + +const { + restoreEscapedNewLine, + restoreEscapedTab, +} = __nccwpck_require__(307); -const buildUpdateMessage = (channelId = "", text = "", ts = "") => { +const buildMessage = (channel = "", text = "", ts = "", optional = {}) => { const message = { - channel: channelId, - text: text, - ts: ts, + channel, + text, + ts, }; + message.text = restoreEscapedNewLine(message.text); + message.text = restoreEscapedTab(message.text); + + Object.keys(optional).forEach((name) => { + message[name] = optional[name]; + }); + return message; }; -module.exports = buildUpdateMessage; +module.exports = buildMessage; /***/ }), @@ -1924,6 +1936,19 @@ const updateMessage = async () => { module.exports = { updateMessage }; +/***/ }), + +/***/ 307: +/***/ ((module) => { + +const restoreEscapedNewLine = (text) => + text.replace(/\\r\\n/g, "\n").replace(/\\n/g, "\n"); + +const restoreEscapedTab = (text) => text.replace(/\\t/g, "\t"); + +module.exports = { restoreEscapedNewLine, restoreEscapedTab }; + + /***/ }), /***/ 491: diff --git a/src/message/build-message.js b/src/message/build-message.js index e379cfb..1ea9b86 100644 --- a/src/message/build-message.js +++ b/src/message/build-message.js @@ -1,3 +1,8 @@ +const { + restoreEscapedNewLine, + restoreEscapedTab, +} = require("../util/escaper.js"); + const buildMessage = (channel = "", text = "", optional = {}) => { const message = { channel, @@ -14,9 +19,4 @@ const buildMessage = (channel = "", text = "", optional = {}) => { return message; }; -const restoreEscapedNewLine = (text) => - text.replace(/\\r\\n/g, "\n").replace(/\\n/g, "\n"); - -const restoreEscapedTab = (text) => text.replace(/\\t/g, "\t"); - module.exports = buildMessage; diff --git a/src/update-message/build-update-message.js b/src/update-message/build-update-message.js index 1ea9f3e..011ddf8 100644 --- a/src/update-message/build-update-message.js +++ b/src/update-message/build-update-message.js @@ -1,11 +1,23 @@ -const buildUpdateMessage = (channelId = "", text = "", ts = "") => { +const { + restoreEscapedNewLine, + restoreEscapedTab, +} = require("../util/escaper.js"); + +const buildMessage = (channel = "", text = "", ts = "", optional = {}) => { const message = { - channel: channelId, - text: text, - ts: ts, + channel, + text, + ts, }; + message.text = restoreEscapedNewLine(message.text); + message.text = restoreEscapedTab(message.text); + + Object.keys(optional).forEach((name) => { + message[name] = optional[name]; + }); + return message; }; -module.exports = buildUpdateMessage; +module.exports = buildMessage; diff --git a/src/util/escaper.js b/src/util/escaper.js new file mode 100644 index 0000000..0e3b2af --- /dev/null +++ b/src/util/escaper.js @@ -0,0 +1,6 @@ +const restoreEscapedNewLine = (text) => + text.replace(/\\r\\n/g, "\n").replace(/\\n/g, "\n"); + +const restoreEscapedTab = (text) => text.replace(/\\t/g, "\t"); + +module.exports = { restoreEscapedNewLine, restoreEscapedTab };