/lita-exclusive-route

A Lita extension to allow exclusive route which only trigger if no prior routes triggered

Primary LanguageRubyMIT LicenseMIT

lita-exclusive-route

Build Status Code Climate Coverage Status

lita-exclusive-route is an extension for Lita that allows handler exclusive routes which only trigger when no prior routes already triggered

Installation

Add lita-exclusive-route to your Lita plugin's gemspec:

spec.add_runtime_dependency "lita-exclusive-route"

Usage

To make route exclusive simply add exclusive: true to it

# example from lita-responder
# this route will catch all chat commands but only if there's no other routes catching it before this
route %r{^(.+)$}, :ask_responder, command: true, exclusive: true

Bonus

It's also possible to get array of routes which caught a chat message by accessing message instance variable :

# inside handler route callback method
response.message.instance_variable_get('@routes') # return array of Lita::Handler::Route triggered before current route

License

MIT