2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-31 06:05:22 +00:00

[Bugfix] don't return Promise from scheduleDeletion

Because when Promise is returned from Telegraf handler,
bot doesn't fetch updates until it settles.

And we do `return reply(...).then(scheduleDeletion)`...
This commit is contained in:
GingerPlusPlus
2017-11-01 21:45:59 +01:00
parent b6e57b4e29
commit 2870b7fa56

View File

@@ -2,10 +2,6 @@
const { telegram } = require('../bot');
const { promisify } = require('util');
const delay = promisify(setTimeout);
const escapeHtml = s => s
.replace(/</g, '&lt;');
@@ -29,12 +25,14 @@ const deleteAfter = ms => ctx =>
ms
);
const scheduleDeletion = async ({ chat, message_id }) => {
const scheduleDeletion = ({ chat, message_id }) => {
if (chat.type === 'private') {
return null;
}
await delay(5 * 60 * 1000);
return telegram.deleteMessage(chat.id, message_id);
return setTimeout(
() => telegram.deleteMessage(chat.id, message_id),
5 * 60 * 1000
);
};
module.exports = {