No commit activity in last 3 years
No release in over 3 years
A Lita extension to require confirmation for commands.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 3.0.0

Runtime

>= 4.0
 Project Readme

lita-confirmation

RubyGems Build Status Code Climate Coverage Status

lita-confirmation is an extension for Lita 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:

spec.add_runtime_dependency "lita-confirmation"

Usage

Basic confirmation

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

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: Lita 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.

route /danger/, :danger, command: true, confirmation: { allow_self: false }
Alice: Lita, danger
Lita: This command requires confirmation. To confirm, send the command: Lita 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.

route /danger/, :danger, command: true, confirmation: { restrict_to: :managers }
Alice: Lita, danger
Lita: This command requires confirmation. To confirm, send the command: Lita 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.

route /danger/, :danger, command: true, confirmation: { expire_after: 10 }
Alice: Lita, danger
Lita: This command requires confirmation. To confirm, send the command: Lita 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