message: Add utc time to log, exit process when connection is closed.
diff: @@ -7,6 +7,16 @@ function JabberBot(configuration) {
  var controller = Botkit(configuration || {});
  + function toUTCDateTimeString(date) {
  + var yyyy = date.getUTCFullYear();
  + var mm = date.getUTCMonth() < 9 ? "0" + (date.getUTCMonth() + 1) : (date.getUTCMonth() + 1); // getMonth() is zero-based
  + var dd = date.getUTCDate() < 10 ? "0" + date.getUTCDate() : date.getUTCDate();
  + var hh = date.getUTCHours() < 10 ? "0" + date.getUTCHours() : date.getUTCHours();
  + var min = date.getUTCMinutes() < 10 ? "0" + date.getUTCMinutes() : date.getUTCMinutes();
  + var ss = date.getUTCSeconds() < 10 ? "0" + date.getUTCSeconds() : date.getUTCSeconds();
  + return "".concat(yyyy).concat('-').concat(mm).concat('-').concat(dd).concat('T').concat(hh).concat(':').concat(min).concat(':').concat(ss);
  + };
  +
  controller.middleware.format.use(function (bot, message, platform_message, next) {
  // clone the incoming message
  for (var k in message) {
  @@ -37,26 +47,28 @@ function JabberBot(configuration) {
  }
  xmpp.on('online', function (data) {
  - console.log('Connected with JID: ' + data.jid.user);
  + console.log(toUTCDateTimeString(new Date()) + ':Connected with JID: ' + data.jid.user);
  console.log('Yes, I\'m connected!');
  request_roster();
  });
  xmpp.on('close', function () {
  - console.log('connection has been closed!');
  + console.log(toUTCDateTimeString(new Date()) + ':connection has been closed!');
  + process.exit();
  });
  xmpp.on('error', function (err) {
  - console.log(err);
  + console.log(toUTCDateTimeString(new Date()) + ":" + err);
  });
  xmpp.on('subscribe', function (from) {
  xmpp.acceptSubscription(from);
  - console.log('accept subscribe from ' + from);
  + console.log(toUTCDateTimeString(new Date()) + ':accept subscribe from:' + from);
  controller.trigger('subscribe', [bot, from]);
  });
  xmpp.on('unsubscribe', function (from) {
  + console.log(toUTCDateTimeString(new Date()) + ':accept unsubscribe from:' + from);
  xmpp.acceptUnsubscription(from);
  });
  