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