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:
12
utils/tg.js
12
utils/tg.js
@@ -2,10 +2,6 @@
|
||||
|
||||
const { telegram } = require('../bot');
|
||||
|
||||
const { promisify } = require('util');
|
||||
|
||||
const delay = promisify(setTimeout);
|
||||
|
||||
const escapeHtml = s => s
|
||||
.replace(/</g, '<');
|
||||
|
||||
@@ -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 = {
|
||||
|
Reference in New Issue
Block a user