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

31 lines
658 B
JavaScript
Raw Normal View History

2017-09-24 23:23:36 +02:00
'use strict';
// Utils
const { escapeHtml } = require('../../utils/tg');
// DB
const { listGroups } = require('../../stores/groups');
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(`<b>Groups I manage</b>:\n${entries}`);
/* TODO: Obtain invite links as well, maybe cache them in db */
};
module.exports = groupsHandler;