UNPKG

@ebonydevcopy/framework

Version:

A module-based NodeJS chatbot framework.

29 lines 678 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * A Text Matcher */ class TextMatcher { constructor() { this.rules = []; } /** * Adds text rules */ importRules(rules) { this.rules = this.rules.concat(rules); } ruleMatcher(message) { const msg = message.text.toUpperCase(); for (const rule of this.rules) { const { regex, action } = rule; if (regex.test(msg)) { regex.lastIndex = 0; return action; } } return false; } } exports.default = TextMatcher; //# sourceMappingURL=TextMatcher.js.map