2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-25 03:17:09 +00:00

36 lines
846 B
JavaScript
Raw Normal View History

2017-09-24 23:23:36 +02:00
'use strict';
// Utils
const { escapeHtml, scheduleDeletion } = require('../../utils/tg');
2017-09-24 23:23:36 +02:00
// DB
2017-09-25 16:17:18 +03:30
const { listGroups } = require('../../stores/group');
2017-09-24 23:23:36 +02:00
const config = require('../../config.json');
const inline_keyboard = config.groupsInlineKeyboard;
const reply_markup = JSON.stringify({ inline_keyboard });
2017-09-25 16:14:29 +03:30
const entry = group => group.username
? `- @${group.username}`
: `- <a href="${group.link}">${escapeHtml(group.title)}</a>`;
2017-09-24 23:23:36 +02:00
const groupsHandler = async ({ replyWithHTML }) => {
2017-09-24 23:23:36 +02:00
if (config.groupsString) {
return replyWithHTML(config.groupsString);
2017-09-24 23:23:36 +02:00
}
const groups = await listGroups();
const entries = groups.map(entry).join('\n');
return replyWithHTML(
`🛠 <b>Groups I manage</b>:\n\n${entries}`, {
disable_web_page_preview: true,
reply_markup,
}).then(scheduleDeletion);
2017-09-24 23:23:36 +02:00
};
module.exports = groupsHandler;