2024-01-24 23:09:32 +00:00
|
|
|
import { SlackAccount } from './classes.slackaccount.js';
|
|
|
|
import { SlackMessage } from './classes.slackmessage.js';
|
2019-09-18 14:47:31 +00:00
|
|
|
|
|
|
|
export class SlackLog {
|
|
|
|
public slackAccount: SlackAccount;
|
|
|
|
public slackMessage: SlackMessage;
|
|
|
|
public channelName: string;
|
|
|
|
|
|
|
|
public completeLog = ``;
|
|
|
|
|
2019-09-18 17:37:45 +00:00
|
|
|
constructor(optionsArg: { slackAccount: SlackAccount; channelName: string }) {
|
2019-09-18 14:47:31 +00:00
|
|
|
this.slackAccount = optionsArg.slackAccount;
|
|
|
|
this.channelName = optionsArg.channelName;
|
|
|
|
}
|
|
|
|
public async sendLogLine(logText: string) {
|
|
|
|
if (!this.slackMessage) {
|
|
|
|
this.slackMessage = new SlackMessage(this.slackAccount, {
|
|
|
|
text: '``` log is loading... ```'
|
|
|
|
});
|
|
|
|
await this.slackMessage.sendToRoom(this.channelName);
|
|
|
|
}
|
|
|
|
const date = new Date();
|
2019-09-18 17:37:45 +00:00
|
|
|
this.completeLog +=
|
|
|
|
`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()} - ` + logText + '\n';
|
2019-09-18 14:47:31 +00:00
|
|
|
await this.slackMessage.updateAndSend({
|
2019-09-18 17:37:45 +00:00
|
|
|
text: '```\n' + this.completeLog + '\n```'
|
|
|
|
});
|
2019-09-18 14:47:31 +00:00
|
|
|
}
|
2019-09-18 17:37:45 +00:00
|
|
|
}
|