Skip to content

Commit 2870b7f

Browse files
committed
[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)`...
1 parent b6e57b4 commit 2870b7f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

utils/tg.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
const { telegram } = require('../bot');
44

5-
const { promisify } = require('util');
6-
7-
const delay = promisify(setTimeout);
8-
95
const escapeHtml = s => s
106
.replace(/</g, '&lt;');
117

@@ -29,12 +25,14 @@ const deleteAfter = ms => ctx =>
2925
ms
3026
);
3127

32-
const scheduleDeletion = async ({ chat, message_id }) => {
28+
const scheduleDeletion = ({ chat, message_id }) => {
3329
if (chat.type === 'private') {
3430
return null;
3531
}
36-
await delay(5 * 60 * 1000);
37-
return telegram.deleteMessage(chat.id, message_id);
32+
return setTimeout(
33+
() => telegram.deleteMessage(chat.id, message_id),
34+
5 * 60 * 1000
35+
);
3836
};
3937

4038
module.exports = {

0 commit comments

Comments
 (0)