2017-09-27 22:17:07 +02:00
|
|
|
'use strict';
|
|
|
|
|
2017-10-04 20:55:50 +03:30
|
|
|
// DB
|
|
|
|
const { listCommands } = require('../../stores/command');
|
|
|
|
|
2018-04-17 17:35:20 +02:00
|
|
|
const { scheduleDeletion } = require('../../utils/tg');
|
|
|
|
|
2017-09-27 22:17:07 +02:00
|
|
|
const commandReference = `\
|
|
|
|
<b>Master commands</b>:
|
2017-09-29 00:02:58 +03:30
|
|
|
<code>/admin</code> - Makes the user admin.
|
|
|
|
<code>/unadmin</code> - Demotes the user from admin list.
|
2017-11-25 14:59:41 +03:30
|
|
|
<code>/leave <name|id></code> - Makes the bot leave the group cleanly.
|
2018-04-17 17:19:27 +02:00
|
|
|
<code>/hidegroup</code> - Hide the group from <code>/groups</code> list.
|
2018-04-03 00:21:00 +02:00
|
|
|
<code>/showgroup</code> - Show the group it in <code>/groups</code> list.
|
2017-09-27 22:17:07 +02:00
|
|
|
|
|
|
|
<b>Admin commands</b>:
|
2017-09-29 00:02:58 +03:30
|
|
|
<code>/warn <reason></code> - Warns the user.
|
|
|
|
<code>/unwarn</code> - Removes the last warn from the user.
|
|
|
|
<code>/nowarns</code> - Clears warns for the user.
|
|
|
|
<code>/ban <reason></code> - Bans the user from groups.
|
|
|
|
<code>/unban</code> - Removes the user from ban list.
|
2017-11-02 16:55:36 +01:00
|
|
|
<code>/user</code> - Shows user's status and warns.
|
2017-11-25 14:59:41 +03:30
|
|
|
<code>/addcommand <name></code> - to create a custom command.
|
|
|
|
<code>/removecommand <name></code> - to remove a custom command.
|
2017-09-27 22:17:07 +02:00
|
|
|
|
|
|
|
<b>Commands for everyone</b>:
|
2017-09-29 00:02:58 +03:30
|
|
|
<code>/staff</code> - Shows a list of admins.
|
2017-10-02 12:09:44 +03:30
|
|
|
<code>/link</code> - Show the current group's link.
|
2017-09-29 00:02:58 +03:30
|
|
|
<code>/groups</code> - Show a list of groups which the bot is admin in.
|
|
|
|
<code>/report</code> - Reports the replied-to message to admins.
|
2017-09-27 22:17:07 +02:00
|
|
|
`;
|
|
|
|
|
2018-04-17 17:35:20 +02:00
|
|
|
const commandReferenceHandler = async ({ replyWithHTML }) => {
|
2017-10-04 20:55:50 +03:30
|
|
|
const customCommands = await listCommands();
|
|
|
|
const customCommandsText = customCommands.length
|
|
|
|
? '\n<b>Custom commands:</b>\n' +
|
|
|
|
customCommands
|
|
|
|
.filter(command => command.isActive)
|
2017-10-11 22:51:44 +03:30
|
|
|
.sort((a, b) => a.role.toLowerCase() < b.role.toLowerCase())
|
|
|
|
.map(command =>
|
|
|
|
`[${command.role.toLowerCase()}] ` +
|
|
|
|
`<code>!${command.name}</code>`)
|
2017-10-04 20:55:50 +03:30
|
|
|
.join('\n')
|
|
|
|
: '';
|
2018-04-17 17:35:20 +02:00
|
|
|
return replyWithHTML(commandReference + customCommandsText)
|
|
|
|
.then(scheduleDeletion);
|
2017-09-28 15:46:49 +03:30
|
|
|
};
|
2017-09-27 22:17:07 +02:00
|
|
|
|
|
|
|
module.exports = commandReferenceHandler;
|