'use strict'; // Utils const { escapeHtml } = require('../../utils/tg'); // DB const { listGroups } = require('../../stores/group'); const config = require('../../config.json'); const entry = group => group.username ? `- @${group.username}` : `- ${escapeHtml(group.title)}`; const groupsHandler = async ctx => { if (config.groupsString) { return ctx.replyWithHTML(config.groupsString); } const groups = await listGroups(); const entries = groups.map(entry).join('\n'); return ctx.replyWithHTML(`🛠 Groups I manage:\n\n${entries}`); }; module.exports = groupsHandler;