<commit_before># lita-confirmation

[![Build Status](https://travis-ci.org/jimmycuadra/lita-confirmation.png?branch=master)](https://travis-ci.org/jimmycuadra/lita-confirmation)
[![Code Climate](https://codeclimate.com/github/jimmycuadra/lita-confirmation.png)](https://codeclimate.com/github/jimmycuadra/lita-confirmation)
[![Coverage Status](https://coveralls.io/repos/jimmycuadra/lita-confirmation/badge.png)](https://coveralls.io/r/jimmycuadra/lita-confirmation)

**lita-confirmation** is an extension for [Lita](https://www.lita.io/) that allows handler routes to require "confirmation" before being triggered. Confirmation consists of a second message sent to the robot with a confirmation code.

## Installation

Add lita-confirmation to your Lita plugin's gemspec:

``` ruby
spec.add_runtime_dependency "lita-confirmation"
```

## Usage

### Basic confirmation

For basic confirmation, simply set the `:confirmation` option to true when defining a route.

``` ruby
route /danger/, :danger, command: true, confirmation: true
```

This will result in the following behavior:

```
Alice: Lita, danger
Lita: This command requires confirmation. To confirm, send the command "confirm 636f308"
Alice: Lita, confirm 636f308
Lita: Dangerous command executed!
```

### Customized confirmation

There are a few different options that can be supplied to customize the way the confirmation behaves. To supply one or more options, pass a hash as the value for the `:confirmation` option instead of just a boolean.

#### allow_self

By default, the same user who initially triggered the command can confirm it. If you want to make it even harder to trigger a command accidentally, you can require that another user send the confirmation command by setting the `:allow_self` option to false.

``` ruby
route /danger/, :danger, command: true, confirmation: { allow_self: false }
```

```
Alice: Lita, danger
Lita: This command requires confirmation. To confirm, send the command "confirm 636f308"
Alice: Lita, confirm 636f308
Lita: Confirmation 636f308 must come from a different user.
Bob: Lita, confirm 636f308
Lita: Dangerous command executed!
```

#### restrict_to

If you want to require that the confirming user be a member of a particular authorization group, use the `:restrict_to` option. The value can be either a string, a symbol, or an array or strings/symbols.

``` ruby
route /danger/, :danger, command: true, confirmation: { restrict_to: :managers }
```

```
Alice: Lita, danger
Lita: This command requires confirmation. To confirm, send the command "confirm 636f308"
Alice: Lita, confirm 636f308
Lita: Confirmation 636f308 must come from a user in one of the following authorization groups: managers
Manager: Lita, confirm 636f308
Lita: Dangerous command executed!
```

#### expire_after

By default, a confirmation must be made within one minute of the original command. After the expiry period, the original command must be sent again, and a new confirmation code will be generated. To change the length of the expiry, set the `:expire_after` value to an integer or string number of seconds.

``` ruby
route /danger/, :danger, command: true, confirmation: { expire_after: 10 }
```

```
Alice: Lita, danger
Lita: This command requires confirmation. To confirm, send the command "confirm 636f308"
Alice: Waiting 15 seconds...
Alice: Lita, confirm 636f308
Lita: 636f308 is not a valid confirmation code. It may have expired. Please run the original command agin.
```

## License

[MIT](http://opensource.org/licenses/MIT)<commit_msg>Fix typo in README.<commit_after># lita-confirmation

[![Build Status](https://travis-ci.org/jimmycuadra/lita-confirmation.png?branch=master)](https://travis-ci.org/jimmycuadra/lita-confirmation)
[![Code Climate](https://codeclimate.com/github/jimmycuadra/lita-confirmation.png)](https://codeclimate.com/github/jimmycuadra/lita-confirmation)
[![Coverage Status](https://coveralls.io/repos/jimmycuadra/lita-confirmation/badge.png)](https://coveralls.io/r/jimmycuadra/lita-confirmation)

**lita-confirmation** is an extension for [Lita](https://www.lita.io/) that allows handler routes to require "confirmation" before being triggered. Confirmation consists of a second message sent to the robot with a confirmation code.

## Installation

Add lita-confirmation to your Lita plugin's gemspec:

``` ruby
spec.add_runtime_dependency "lita-confirmation"
```

## Usage

### Basic confirmation

For basic confirmation, simply set the `:confirmation` option to true when defining a route.

``` ruby
route /danger/, :danger, command: true, confirmation: true
```

This will result in the following behavior:

```
Alice: Lita, danger
Lita: This command requires confirmation. To confirm, send the command "confirm 636f308"
Alice: Lita, confirm 636f308
Lita: Dangerous command executed!
```

### Customized confirmation

There are a few different options that can be supplied to customize the way the confirmation behaves. To supply one or more options, pass a hash as the value for the `:confirmation` option instead of just a boolean.

#### allow_self

By default, the same user who initially triggered the command can confirm it. If you want to make it even harder to trigger a command accidentally, you can require that another user send the confirmation command by setting the `:allow_self` option to false.

``` ruby
route /danger/, :danger, command: true, confirmation: { allow_self: false }
```

```
Alice: Lita, danger
Lita: This command requires confirmation. To confirm, send the command "confirm 636f308"
Alice: Lita, confirm 636f308
Lita: Confirmation 636f308 must come from a different user.
Bob: Lita, confirm 636f308
Lita: Dangerous command executed!
```

#### restrict_to

If you want to require that the confirming user be a member of a particular authorization group, use the `:restrict_to` option. The value can be either a string, a symbol, or an array or strings/symbols.

``` ruby
route /danger/, :danger, command: true, confirmation: { restrict_to: :managers }
```

```
Alice: Lita, danger
Lita: This command requires confirmation. To confirm, send the command "confirm 636f308"
Alice: Lita, confirm 636f308
Lita: Confirmation 636f308 must come from a user in one of the following authorization groups: managers
Manager: Lita, confirm 636f308
Lita: Dangerous command executed!
```

#### expire_after

By default, a confirmation must be made within one minute of the original command. After the expiry period, the original command must be sent again, and a new confirmation code will be generated. To change the length of the expiry, set the `:expire_after` value to an integer or string number of seconds.

``` ruby
route /danger/, :danger, command: true, confirmation: { expire_after: 10 }
```

```
Alice: Lita, danger
Lita: This command requires confirmation. To confirm, send the command "confirm 636f308"
Alice: Waiting 15 seconds...
Alice: Lita, confirm 636f308
Lita: 636f308 is not a valid confirmation code. It may have expired. Please run the original command again.
```

## License

[MIT](http://opensource.org/licenses/MIT)
{'fraction_non_alphanumeric': 0.09555398729710657, 'fraction_numerical': 0.023147494707127736, 'mean_word_length': 5.113891285591027, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 14, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1233978', 'n_tokens_mistral': 2241, 'n_tokens_neox': 1997, 'n_words': 854}