mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-09-01 14:45:27 +00:00
delete /groups and /link responses after 5 min
This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
// Utils
|
// Utils
|
||||||
const { escapeHtml } = require('../../utils/tg');
|
const { escapeHtml } = require('../../utils/tg');
|
||||||
|
|
||||||
|
// Bot
|
||||||
|
const bot = require('../../bot');
|
||||||
|
|
||||||
// DB
|
// DB
|
||||||
const { listGroups } = require('../../stores/group');
|
const { listGroups } = require('../../stores/group');
|
||||||
|
|
||||||
@@ -16,20 +19,24 @@ const entry = group => group.username
|
|||||||
? `- @${group.username}`
|
? `- @${group.username}`
|
||||||
: `- <a href="${group.link}">${escapeHtml(group.title)}</a>`;
|
: `- <a href="${group.link}">${escapeHtml(group.title)}</a>`;
|
||||||
|
|
||||||
const groupsHandler = async ctx => {
|
const groupsHandler = async ({ chat, replyWithHTML }) => {
|
||||||
if (config.groupsString) {
|
if (config.groupsString) {
|
||||||
return ctx.replyWithHTML(config.groupsString);
|
return replyWithHTML(config.groupsString);
|
||||||
}
|
}
|
||||||
|
|
||||||
const groups = await listGroups();
|
const groups = await listGroups();
|
||||||
|
|
||||||
const entries = groups.map(entry).join('\n');
|
const entries = groups.map(entry).join('\n');
|
||||||
|
|
||||||
return ctx.replyWithHTML(`🛠 <b>Groups I manage</b>:\n\n${entries}`, {
|
const { message_id } = await replyWithHTML(
|
||||||
|
`🛠 <b>Groups I manage</b>:\n\n${entries}`, {
|
||||||
disable_web_page_preview: true,
|
disable_web_page_preview: true,
|
||||||
reply_markup,
|
reply_markup,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return setTimeout(() =>
|
||||||
|
bot.telegram.deleteMessage(chat.id, message_id), 5 * 60 * 1000);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = groupsHandler;
|
module.exports = groupsHandler;
|
||||||
|
@@ -1,15 +1,20 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
// Bot
|
||||||
|
const bot = require('../../bot');
|
||||||
|
|
||||||
// DB
|
// DB
|
||||||
const { managesGroup } = require('../../stores/group');
|
const { managesGroup } = require('../../stores/group');
|
||||||
|
|
||||||
const linkHandler = async ({ chat, replyWithHTML }) => {
|
const linkHandler = async ({ chat, replyWithHTML }) => {
|
||||||
const group = await managesGroup(chat);
|
const group = await managesGroup(chat);
|
||||||
|
|
||||||
return replyWithHTML(
|
const { message_id } = await replyWithHTML(
|
||||||
'ℹ️ <b>Group\'s link:</b>\n\n' +
|
'ℹ️ <b>Group\'s link:</b>\n\n' +
|
||||||
`<a href="${group.link}">${group.title}</a>`
|
`<a href="${group.link}">${group.title}</a>`
|
||||||
);
|
);
|
||||||
|
return setTimeout(() =>
|
||||||
|
bot.telegram.deleteMessage(chat.id, message_id), 5 * 60 * 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = linkHandler;
|
module.exports = linkHandler;
|
||||||
|
Reference in New Issue
Block a user