2020-08-29 06:52:33 +00:00
|
|
|
import autobind from 'autobind-decorator';
|
2020-09-19 01:40:44 +00:00
|
|
|
import Module from '@/module';
|
|
|
|
import serifs from '@/serifs';
|
2020-08-29 06:52:33 +00:00
|
|
|
|
|
|
|
export default class extends Module {
|
|
|
|
public readonly name = 'sleepReport';
|
|
|
|
|
|
|
|
@autobind
|
|
|
|
public install() {
|
|
|
|
this.report();
|
|
|
|
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
@autobind
|
|
|
|
private report() {
|
|
|
|
const now = Date.now();
|
|
|
|
|
|
|
|
const sleepTime = now - this.ai.lastSleepedAt;
|
|
|
|
|
|
|
|
const sleepHours = sleepTime / 1000 / 60 / 60;
|
|
|
|
|
|
|
|
if (sleepHours < 0.1) return;
|
|
|
|
|
|
|
|
if (sleepHours >= 1) {
|
|
|
|
this.ai.post({
|
|
|
|
text: serifs.sleepReport.report(Math.round(sleepHours))
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.ai.post({
|
|
|
|
text: serifs.sleepReport.reportUtatane
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|