<commit_before>'use strict';

class BotStrategyBase {

  constructor(name) {
    this.name = name;
  }

  getKeys() {
    this._raise('getKey');
  }

  getUsage() {
    this._raise('getUsage');
  }

  canHandle() {
    this._raise('canHandle');
  }

  handle(message, key) {
    return Promise.resolve(this._raise('handle'));
  }

  _raise(methodName) {
    throw new Error(`'${methodName}' method not set for ${this.class.name}`);
  }
}

module.exports = BotStrategyBase;
<commit_msg>Add basic implementation for canHandle in BotStrategyBase<commit_after>'use strict';

class BotStrategyBase {

  constructor(name) {
    this.name = name;
  }

  getKeys() {
    this._raise('getKeys');
  }

  getUsage() {
    this._raise('getUsage');
  }

  handle(message, key) {
    return Promise.resolve(this._raise('handle'));
  }

  _raise(methodName) {
    throw new Error(`'${methodName}' method not set for ${this.class.name}`);
  }

  canHandle(message) {
    return this.getKey(message) != null;
  }

  getKey(message) {
    return this.getKeys().find( key => { return message.text.indexOf(key) !== -1 }) || null;
  }

}

module.exports = BotStrategyBase;

{'fraction_non_alphanumeric': 0.1623263888888889, 'fraction_numerical': 0.0008680555555555555, 'mean_word_length': 3.4689922480620154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4298951', 'n_tokens_mistral': 394, 'n_tokens_neox': 384, 'n_words': 72}