I have a simple Hubot script that is looking for certain trigger words, then replying with a URL based on those trigger words.
A slightly contrived example:
robot.hear /CAT/i, (msg) ->
msg.send "This is a URL - www.example.com/browse/cats"
robot.hear /YELLOWBIRD/i, (msg) ->
msg.send "This is a URL - www.example.com/browse/yellowbirds"
robot.hear /BIRD/i, (msg) ->
msg.send "This is a URL - www.example.com/browse/birds"
The problem is, one of the trigger words (BIRD) is a substring of another trigger word (YELLOWBIRD).
In this case, I want to only trigger on the more specific regex (YELLOWBIRD).
However, Hubot is currently triggering on both regexes - i.e. it will send in:
This is a URL - www.example.com/browse/yellowbirds
This is a URL - www.example.com/browse/birds
Is there a way to have Hubot treat the list of regexes like a case - as in, it will work through them from the top, and the first one it hits, it will break out, and not process the remaining ones? (Or maybe there's a way to make the "BIRD" regex ignore if if there's a yellow there).
And bonus question - is there perhaps a better or more idiomatic way of organising these regexes and replies? Some kind of lookup table or something?