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

Added and used scheduleDeletion

...only where I was certain that whis was a good idea,
perhaps it could be useful in more places.
This commit is contained in:
GingerPlusPlus
2017-10-31 22:20:49 +01:00
parent 84e178f363
commit 337f6e2183
12 changed files with 45 additions and 37 deletions

View File

@@ -1,5 +1,11 @@
'use strict';
const { telegram } = require('../bot');
const { promisify } = require('util');
const delay = promisify(setTimeout);
const escapeHtml = s => s
.replace(/</g, '&lt;');
@@ -21,9 +27,18 @@ const deleteAfter = ms => ctx =>
ctx.telegram.deleteMessage(ctx.chat.id, ctx.message.message_id),
ms);
const scheduleDeletion = async ({ chat, message_id }) => {
if (chat.type === 'private') {
return null;
}
await delay(5 * 60 * 1000);
return telegram.deleteMessage(chat.id, message_id);
};
module.exports = {
deleteAfter,
escapeHtml,
link,
quietLink,
scheduleDeletion,
};