message: handle facebook scope issues
diff: @@ -240,42 +240,7 @@ function Facebookbot(configuration) {
  // return info about the specific instance of this bot
  // including identity information, and any other info that is relevant
  bot.getInstanceInfo = function(cb) {
  -
  - return new Promise(function(resolve, reject) {
  - var instance = {
  - identity: {},
  - team: {},
  - };
  -
  - request.get('https://' + api_host + '/v2.6/me?access_token=' + configuration.access_token,
  - {},
  - function(err, res, body) {
  - if (err) {
  - if (cb) cb(err);
  - return reject(err);
  - } else {
  -
  - var identity = null;
  - try {
  - identity = JSON.parse(body);
  - } catch (err) {
  - if (cb) cb(err);
  - return reject(err);
  - }
  -
  - // for facebook, the bot and the page have the same identity
  - instance.identity.name = identity.name;
  - instance.identity.id = identity.id;
  -
  - instance.team.name = identity.name;
  - instance.team.url = 'http://facebook.com/' + identity.id;
  - instance.team.id = identity.id;
  -
  - if (cb) cb(null, instance);
  - resolve(instance);
  - }
  - });
  - });
  + return facebook_botkit.getInstanceInfo(cb);
  }
  bot.getMessageUser = function(message, cb) {
  @@ -315,6 +280,48 @@ function Facebookbot(configuration) {
  return bot;
  });
  + // return info about the specific instance of this bot
  + // including identity information, and any other info that is relevant
  + // unlike other platforms, this has to live on the controller
  + // so that we can use it before a bot is spawned!
  + facebook_botkit.getInstanceInfo = function(cb) {
  + return new Promise(function(resolve, reject) {
  + var instance = {
  + identity: {},
  + team: {},
  + };
  +
  + request.get('https://' + api_host + '/v2.6/me?access_token=' + configuration.access_token,
  + {},
  + function(err, res, body) {
  + if (err) {
  + if (cb) cb(err);
  + return reject(err);
  + } else {
  +
  + var identity = null;
  + try {
  + identity = JSON.parse(body);
  + } catch (err) {
  + if (cb) cb(err);
  + return reject(err);
  + }
  +
  + // for facebook, the bot and the page have the same identity
  + instance.identity.name = identity.name;
  + instance.identity.id = identity.id;
  +
  + instance.team.name = identity.name;
  + instance.team.url = 'http://facebook.com/' + identity.id;
  + instance.team.id = identity.id;
  +
  + if (cb) cb(null, instance);
  + resolve(instance);
  + }
  + });
  + });
  + }
  +
  // set up a web route for receiving outgoing webhooks and/or slash commands
  facebook_botkit.createWebhookEndpoints = function(webserver, bot, cb) {
  @@ -856,7 +863,7 @@ function Facebookbot(configuration) {
  facebook_botkit.getInstanceInfo().then(function(instance) {
  - controller.identity = instance.identity;
  + facebook_botkit.identity = instance.identity;
  }).catch(function(err) {
  