mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-31 14:15:25 +00:00
Added /groups
This commit is contained in:
30
handlers/commands/groups.js
Normal file
30
handlers/commands/groups.js
Normal file
@@ -0,0 +1,30 @@
|
||||
'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;
|
Reference in New Issue
Block a user