How to use the hubot/es2015.Robot function in hubot

To help you get started, we’ve selected a few hubot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mtsmfm / hubot-test-helper / src / index.js View on Github external
const Fs    = require('fs');
const Path  = require('path');
const Hubot = require('hubot/es2015');

process.setMaxListeners(0);

class MockResponse extends Hubot.Response {
  sendPrivate(/* ...strings*/) {
    const strings = [].slice.call(arguments, 0);

    this.robot.adapter.sendPrivate.apply(this.robot.adapter, [this.envelope].concat(strings));
  }
}

class MockRobot extends Hubot.Robot {
  constructor(httpd) {
    if (httpd == null) { httpd = true; }
    super(null, null, httpd, 'hubot');

    this.messagesTo = {};

    this.Response = MockResponse;
  }

  messageRoom(roomName, str) {
    if (roomName == this.adapter.name) {
      this.adapter.messages.push(['hubot', str]);
    } else {
      if (!(roomName in this.messagesTo)) {
        this.messagesTo[roomName] = [];
      }