Skip to content

Commit 1f693bf

Browse files
committed
added /link command
1 parent 0f42c9e commit 1f693bf

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Command | Rule | Description
3232
`/ban <reason>` | _Admin_ | Bans the user from groups.
3333
`/unban` | _Admin_ | Removes the user from ban list.
3434
`/staff` | _All_ | Shows a list of admins.
35+
`/link` | _All_ | Show the current group's link.
3536
`/groups` | _All_ | Show a list of groups which the bot is admin in.
3637
`/report` | _All_ | Reports the replied-to message to admins.
3738

handlers/commands/commands.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const commandReference = `\
1616
1717
<b>Commands for everyone</b>:
1818
<code>/staff</code> - Shows a list of admins.
19+
<code>/link</code> - Show the current group's link.
1920
<code>/groups</code> - Show a list of groups which the bot is admin in.
2021
<code>/report</code> - Reports the replied-to message to admins.
2122
`;

handlers/commands/link.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
// DB
4+
const { managesGroup } = require('../../stores/group');
5+
6+
const linkHandler = async ({ chat, replyWithHTML }) => {
7+
const group = await managesGroup(chat);
8+
9+
return replyWithHTML(
10+
'ℹ️ <b>Group\'s link:</b>\n\n' +
11+
`<a href="${group.link}">${group.title}</a>`
12+
);
13+
};
14+
15+
module.exports = linkHandler;

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const banHandler = require('./handlers/commands/ban');
3232
const unbanHandler = require('./handlers/commands/unban');
3333
const reportHandler = require('./handlers/commands/report');
3434
const staffHandler = require('./handlers/commands/staff');
35+
const linkHandler = require('./handlers/commands/link');
3536
const groupsHandler = require('./handlers/commands/groups');
3637
const commandReferenceHandler = require('./handlers/commands/commands');
3738
const helpHandler = require('./handlers/commands/help');
@@ -56,6 +57,7 @@ bot.command('unban', unbanHandler);
5657
bot.command('report', reportHandler);
5758
bot.hears(/^@admins?$/i, reportHandler);
5859
bot.command('staff', staffHandler);
60+
bot.command('link', linkHandler);
5961
bot.command('groups', groupsHandler);
6062
bot.command('commands', commandReferenceHandler);
6163
bot.command([ 'start', 'help' ], helpHandler);

0 commit comments

Comments
 (0)