Skip to content

Commit

Permalink
Building final messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kopiro committed Nov 12, 2023
1 parent c3f17e1 commit 17ce484
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,12 @@ function notifyChange(bot, chatIds, element) {

return Promise.all(
chatIds.map(async chatId => {
let finalMessage;
const finalOpt = { parse_mode: "html", disable_web_page_preview: false };

if (message && url) {
finalMessage = `${message}${newLine}${url}`;
} else if (message && !url) {
finalOpt.disable_web_page_preview = true;
finalMessage = message;
} else if (!message && url) {
finalMessage = url;
}

if (footer) {
finalMessage = `${finalMessage}${newLine}${newLine}<i>${footer}</i>`;
}
const finalMessage = [message, url, footer ? `<i>${footer}</i>` : null]
.map(e => (e ? e.trim() : e))
.filter(e => e)
.join(newLine);

if (finalMessage) {
const result = await bot.sendMessage(chatId, finalMessage, finalOpt);
Expand Down

0 comments on commit 17ce484

Please sign in to comment.