Simp-O-Matic

Dumb Discord bot in TS.
git clone git://git.knutsen.co/Simp-O-Matic
Log | Files | Refs | README | LICENSE

commit 23ea6d7004f2fcb84ff05c3f179540b603b4dd42
parent d95662a96d46f12bdd118d6c3906f88f1da9beb8
Author: Demonstrandum <moi@knutsen.co>
Date:   Sat, 16 May 2020 18:38:24 +0100

Updated HELP for !listen command.

Diffstat:
MHELP.md | 2++
Mlib/commands/listen.ts | 10+++++++---
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/HELP.md b/HELP.md @@ -62,6 +62,8 @@ - `!reject <ls>` — numerically lists all rejection rules. - `!reject rm #[rule-index]` — removes the rejection-rule specified by a numerical index. - `!replace` **〈not impl.〉** — Bots currently do not have the ability to edit other users messages. We can only wait. +- `!listen` — Specify rules only to listen yo specific users: + - `!listen [rule-type] #[rule-index] [...@username(s)]` — Will cause rule at index `#rule-index` of certain `rule-type` (either `respond`, `reject`, `replace` or `trigger`) to only work on specified username(s). - `!cron` — Run commands repeatedly based on some timer (look-up cron syntax for more info): - `!cron [minute] [hour] [day-of-month] [month] [day-of-week] ![command] <...>` — runs a command (with or without arguments) repeatedly as specified by the schedule signature. - `!cron <ls>` — lists all active cron-jobs numerically. diff --git a/lib/commands/listen.ts b/lib/commands/listen.ts @@ -1,5 +1,5 @@ const RULES = [ - 'reply', 'reject', + 'respond', 'reject', 'replace', 'trigger' ]; @@ -9,10 +9,14 @@ export default (home_scope: HomeScope) => { const rule_type = args[0]; if (!RULES.includes(rule_type)) return message.answer("`listen` command first argument must" - + " be either `reply`, `reject`, `replace` or `trigger`" + + " be either `respond`, `reject`, `replace` or `trigger`" + "\nSee `help` page for `listen` for more information."); - const index = Number(args[1].trim()); + const index_str = args[1].trim(); + const index = Number(index_str[0] === '#' + ? index_str.tail() + : index_str); + if (!index) return message.answer("Second argument must be a number" + " (greater than zero), that represents the index of the rule");