message: Fetch joined roomids on startup.
  Don't join mapped rooms if joined.
diff: @@ -28,6 +28,7 @@ var Provisioner = require("../provisioning/Provisioner.js");
  var PublicitySyncer = require("./PublicitySyncer.js");
  const DELAY_TIME_MS = 10 * 1000;
  +const DELAY_FETCH_ROOM_LIST_MS = 3 * 1000;
  const DEAD_TIME_MS = 5 * 60 * 1000;
  const ACTION_TYPE_TO_MSGTYPE = {
  message: "m.text",
  @@ -44,6 +45,7 @@ function IrcBridge(config, registration) {
  this.memberListSyncers = {
  // domain: MemberListSyncer
  };
  + this.joinedRoomList = [];
  // Dependency graph
  this.matrixHandler = new MatrixHandler(this);
  @@ -431,6 +433,10 @@ IrcBridge.prototype.isStartedUp = function() {
  IrcBridge.prototype._joinMappedMatrixRooms = Promise.coroutine(function*() {
  let roomIds = yield this.getStore().getRoomIdsFromConfig();
  let promises = roomIds.map((roomId) => {
  + if (this.joinedRoomList.includes(roomId)) {
  + log.debug(`Not joining ${roomId} because we are marked as joined`);
  + return Promise.resolve();
  + }
  return this._bridge.getIntent().join(roomId);
  });
  yield promiseutil.allSettled(promises);
  @@ -801,7 +807,7 @@ IrcBridge.prototype._loginToServer = Promise.coroutine(function*(server) {
  });
  }, 500 * num);
  num += 1;
  - });
  + });yield
  });
  IrcBridge.prototype.checkNickExists = function(server, nick) {
  @@ -900,19 +906,26 @@ IrcBridge.prototype.getBotClient = function(server) {
  });
  }
  -IrcBridge.prototype._fetchJoinedRooms = function*() {
  +IrcBridge.prototype._fetchJoinedRooms = Promise.coroutine(function*() {
  const bot = this._bridge.getBot();
  + const gotRooms = false;
  + while (!gotRooms) {
  try {
  const roomids = yield bot.getJoinedRooms();
  - console.log(roomids);
  + gotRooms = true;
  + this.joinedRoomList = roomids;
  + log.info(`ASBot is in ${roomids.length} rooms!`);
  }
  catch (ex) {
  // We should retry this, because it's still quicker than rejoining everything.
  - console.log(ex);
  + log.error(`Failed to fetch roomlist from joined_rooms: ${ex}. Retrying`);
  + yield Promise.delay(DELAY_FETCH_ROOM_LIST_MS); // wait a bit before retrying
  }
  -
  }
  +
  +});
  +
  IrcBridge.DEFAULT_LOCALPART = "appservice-irc";
  module.exports = IrcBridge;
  