From 027f9262779ed7127dc4110266a1ff801ddb14e7 Mon Sep 17 00:00:00 2001 From: Luca8991 Date: Fri, 20 Aug 2021 22:21:43 +0200 Subject: [PATCH] feat: alert on pinned message by user --- index.js | 4 ++++ src/constants.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/index.js b/index.js index 258ad38..445cac1 100644 --- a/index.js +++ b/index.js @@ -476,6 +476,10 @@ bot.on('text', async (ctx) => { } }); +bot.on('pinned_message', async (ctx) => { + return ctx.replyWithMarkdown(constants.pinnedMessageAlert(ctx.chat.id)); +}); + bot.catch((err, ctx) => { return ctx.reply(`Ooops, encountered an error for ${ctx.updateType}`, err); }); diff --git a/src/constants.js b/src/constants.js index 7d47784..5a2e7f2 100644 --- a/src/constants.js +++ b/src/constants.js @@ -34,6 +34,8 @@ const moveFileMessage = 'MOVE FILE:\n'; const fileSystemNotFound = 'Filesystem not found'; const genericError = 'Error!\nUse one of the available commands instead:'; +const pinnedMessageAlert = (chatId) => `Please, make sure that the *last* pinned message is always the \`filesystem${chatId}.json\` file, otherwise _the bot won't work_!`; + /* INLINE BUTTONS */ const mkdirInlineButton = Markup.button.callback( '+ New Directory', @@ -84,6 +86,8 @@ module.exports = { fileSystemNotFound, genericError, + pinnedMessageAlert, + mkdirInlineButton, parentDirInlineButton, thisDirInlineButton,