Hubot generally expects scripts to have headers of the form:
# Commands:
# hubot foo - Hubot says foo.
However, what if I want to dynamically define the text trigger for my command? E.g. if I have a command:
fooCommandText = process.env.HUBOT_FOO_COMMAND || 'foo'
module.exports = (robot) ->
robot.respond ///#{fooCommandText}///, (response) ->
response.send 'foo'
I still want hubot help
to work, but I can't use a static header to define what my command looks like.
Looking at robot.coffee in Hubot itself, I can see parseHelp
explicitly reads the script file and parses the header.
How can I make hubot help
work for a command whose text trigger is dynamic?
You can append to robot.commands
instead of defining a help block:
module.exports = (robot) ->
robot.commands.push "hubot #{fooCommandText} - Hubot says foo."