jimmycuadra/lita — pull request #41 by esigler (2014-03-12 21:55:06+00:00)
Title: Add Guard word support to commands

This is a proposal to add a setting to routes (commands specifically), to allow them to require a guard word. The use case is to provide an extra layer of defense for commands. In many chat clients, "lita do_something_scary" is one up-arrow away in history.

I'm sending this PR now as a functional draft to get feedback. In particular, I don't know that I like responding to the message in the route_applies? function, but I don't see a better place to put it without more significant refactoring. (I also had to adjust two Rubocop values, which also would have required more in-depth changes.)

Example current usage:

```
Lita > something
Lita > something GUARD=foobar
Lita > lita scary_command
That command requires GUARD=foobar appended to the end
Lita > lita scary_command GUARD=foo
That command requires GUARD=foobar appended to the end
Lita > lita scary_command GUARD=foobar
(Does scary things)
```

One thing this PR is lacking in particular right now, is a rotating guard word. Without it, it's rather easy to still get in trouble. I'm probably going to set it to use an array of words, selected on a deterministic rotation. Something like:

``` ruby
guard_words = ['foo', 'bar', 'baz']
guard_frequency = daily
```

To enable "GUARD=foo" on Monday, "GUARD=bar" on Tuesday, etc. Any feedback would be appreciated!