2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-31 22:25:15 +00:00

Use router instead of composer in commands/index

+ Makes commands case-insensitive
+ Avoids hardcoding commands in commands/addCommand
This commit is contained in:
GingerPlusPlus
2018-05-20 12:07:12 +02:00
parent 23e6b78f05
commit 642f2e99c3
4 changed files with 56 additions and 35 deletions

View File

@@ -2,6 +2,15 @@
const { telegram } = require('../bot');
const R = require('ramda');
const isCommand = R.pipe(
R.defaultTo({}),
R.path([ 'entities', 0 ]),
R.defaultTo({}),
R.whereEq({ offset: 0, type: 'bot_command' }),
);
const escapeHtml = s => s
.replace(/</g, '&lt;');
@@ -36,6 +45,7 @@ const scheduleDeletion = ({ chat, message_id }) => {
module.exports = {
deleteAfter,
escapeHtml,
isCommand,
link,
quietLink,
scheduleDeletion,