hubot-regex-response

Respond messages by RegExp configs

Usage no npm install needed!

<script type="module">
  import hubotRegexResponse from 'https://cdn.skypack.dev/hubot-regex-response';
</script>

README

hubot-regex-response

NPM version NPM downloads Build Status Dependency Status DevDependency Status License

Respond messages by RegExp configs.

Installation

npm install hubot-regex-response --save

Then add hubot-regex-response to your external-scripts.json:

["hubot-regex-response"]

Sample Interaction

User> hey hey moqada is okada
Hubot> moqada is  okama

User> i love potato
Hubot> User: potato

This interactions configured following configs.

[
  {
    "from": "(moqada is )okada",
    "to": "<%= m[1] %> okama",
  },
  {
    "from": "(potato)",
    "to": "<%= m[1] %>",
    "method": "reply"

  }
]

to Environment variables.

export HUBOT_REGEX_RESPONSE_CONFIGS='[{"from":"(moqada is )okada","to":"<%= m[1] %> okama"},{"from":"(potato)","to":"<%= m[1] %>","method":"reply"}]'

Commands

<config_from_text> - Reply or Send config_to_text

Configurations

HUBOT_REGEX_RESPONSE_CONFIGS - Set JSON string for config response

This JSON string is Array of following Object.

  • from: Target messages (using RegExp string)
  • to: Template of Responding message (using lodash.template)
  • method: send or reply (optional, default: send)

See Sample configs at section of Sample Interaction