lib/lita/handlers/wtf.rb in lita-wtf-1.1.0 vs lib/lita/handlers/wtf.rb in lita-wtf-1.3.0

- old
+ new

@@ -8,19 +8,28 @@ 'merriam' => 'Merriam-Webster Collegiate Dictionary', 'urbandictionary' => 'UrbanDictionary' }.freeze route( - /^wtf(?:\s+is)?\s(?<term>[^\s@#]+)(?:\?)?/, + /^wtf(?:\s+is)?\s+(?<term>[^\s@#]+)(?:\?)?/, :lookup, command: true, help: { t('help.wtf.syntax') => t('help.wtf.desc') } ) route( + /^what(?:\s+is)?\s+(?<term>[^\s@#]+)(?:\?)?/, + :lookup, + command: true, + help: { + t('help.wtf.syntax') => t('help.wtf.desc') + } + ) + + route( /^define\s(?<term>[^\s@#]+)\sis\s(?<definition>[^#@]+)$/, :define, command: true, help: { t('help.define.syntax') => t('help.define.desc') @@ -30,13 +39,16 @@ def lookup(response) term = response.match_data['term'] return response.reply(format_definition(term, definition(term))) if known?(term) definition, source_name = alternate_definition(term) - return response.reply(t('wtf.seealso', - term: term, - definition: definition, - source: SOURCE_NAMES[source_name])) if definition + + if definition + return response.reply(t('wtf.seealso', + term: term, + definition: definition, + source: SOURCE_NAMES[source_name])) + end response.reply(t('wtf.unknown', term: term)) end def define(response)