Browse Source

Adding to startup and shutdown messages

develop
Drew Short 4 years ago
parent
commit
736645d29a
  1. 6
      src/bot.ts
  2. 2
      src/utility.ts

6
src/bot.ts

@ -10,11 +10,13 @@ class Bot {
config: any;
buildInfo: string;
connected: boolean;
startTime: Date;
constructor(config, buildInfo) {
this.config = config;
this.buildInfo = buildInfo;
this.connected = false;
this.startTime = new Date();
}
/**
@ -151,7 +153,7 @@ class Bot {
this.config.statusRooms.forEach(roomId => {
logger.debug("Notifying %s of startup", roomId);
promises.push(this.client.sendMessage(
roomId, message.createBasic("Started with version: " + this.buildInfo, message.types.NOTICE)
roomId, message.createBasic(`Started at ${utility.toISODateString(this.startTime)} with version: ${this.buildInfo}`, message.types.NOTICE)
).then(() => {
logger.debug("Notified %s of startup", roomId);
}, (err) => {
@ -170,7 +172,7 @@ class Bot {
this.config.statusRooms.forEach(roomId => {
logger.debug("Notifying %s of shutdown", roomId);
promises.push(this.client.sendMessage(
roomId, message.createBasic("Shutting down", message.types.NOTICE)
roomId, message.createBasic(`Shutting down at ${utility.toISODateString(new Date())} with version: ${this.buildInfo}`, message.types.NOTICE)
).then(() => {
logger.debug("Notified %s of shutdown", roomId);
}, (err) => {

2
src/utility.ts

@ -29,7 +29,7 @@ function toISODateString(d: Date) {
function getBuildInfo() {
let buildInfoPath = process.env.NODE_PATH + '/build.info';
try {
return fs.readFileSync(buildInfoPath, "utf8");
return fs.readFileSync(buildInfoPath, "utf8").trim();
} catch (err) {
if (err.code === 'ENOENT') {
return "UNKNOWN_" + toISODateString(new Date());

Loading…
Cancel
Save