2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-09-02 15:15:20 +00:00

added /link command

This commit is contained in:
Pouria Ezzati
2017-10-02 12:09:44 +03:30
parent 0f42c9ee55
commit 1f693bf3d0
4 changed files with 19 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ Command | Rule | Description
`/ban <reason>` | _Admin_ | Bans the user from groups.
`/unban` | _Admin_ | Removes the user from ban list.
`/staff` | _All_ | Shows a list of admins.
`/link` | _All_ | Show the current group's link.
`/groups` | _All_ | Show a list of groups which the bot is admin in.
`/report` | _All_ | Reports the replied-to message to admins.

View File

@@ -16,6 +16,7 @@ const commandReference = `\
<b>Commands for everyone</b>:
<code>/staff</code> - Shows a list of admins.
<code>/link</code> - Show the current group's link.
<code>/groups</code> - Show a list of groups which the bot is admin in.
<code>/report</code> - Reports the replied-to message to admins.
`;

15
handlers/commands/link.js Normal file
View File

@@ -0,0 +1,15 @@
'use strict';
// DB
const { managesGroup } = require('../../stores/group');
const linkHandler = async ({ chat, replyWithHTML }) => {
const group = await managesGroup(chat);
return replyWithHTML(
' <b>Group\'s link:</b>\n\n' +
`<a href="${group.link}">${group.title}</a>`
);
};
module.exports = linkHandler;

View File

@@ -32,6 +32,7 @@ const banHandler = require('./handlers/commands/ban');
const unbanHandler = require('./handlers/commands/unban');
const reportHandler = require('./handlers/commands/report');
const staffHandler = require('./handlers/commands/staff');
const linkHandler = require('./handlers/commands/link');
const groupsHandler = require('./handlers/commands/groups');
const commandReferenceHandler = require('./handlers/commands/commands');
const helpHandler = require('./handlers/commands/help');
@@ -56,6 +57,7 @@ bot.command('unban', unbanHandler);
bot.command('report', reportHandler);
bot.hears(/^@admins?$/i, reportHandler);
bot.command('staff', staffHandler);
bot.command('link', linkHandler);
bot.command('groups', groupsHandler);
bot.command('commands', commandReferenceHandler);
bot.command([ 'start', 'help' ], helpHandler);