Example #1
0
  sayMessage(message) {
    expect(message).to.be.an.object().and.to.include(['text', 'channel']);

    return Rx.Observable
      .fromNodeCallback(this._bot.say)(message)
      .doOnError(err => this._logger
        .error(`Failed to send a message to channel ${message.channel}: ${err}`)
      );
  }
Example #2
0
 getUsers() {
   return Rx.Observable
     .fromNodeCallback(this._bot.api.users.list)({})
     .map(response => (response || {}).members)
     .do(
       users => {
         this._logger.debug(`Got ${(users || []).length} users on the team`);
       },
       err => {
         this._logger.error(`Failed to get users on the team: ${err}`);
       }
     );
 }
Example #3
0
 getChannels() {
   return Rx.Observable
     .fromNodeCallback(this._bot.api.channels.list)({})
     .map(response => (response || {}).channels)
     .do(
       channels => {
         this._logger.debug(`Got ${(channels || []).length} channels on ' +
           'the team`);
       },
       err => {
         this._logger.error(`Failed to get channels on the team: ${err}`);
       }
     );
 }
 .flatMap(body => Rx.Observable.fromNodeCallback(jsonParse)(body))