refactor water me service
remove "text-based-feature" improve messages service interface implement more features for fluxer
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
import { TextBasedFeature } from "features/text-based-feature/text-based-feature";
|
||||
import type { TextBasedFeatureInput } from "features/text-based-feature/text-based-feature.schema";
|
||||
import type { MessagesServiceInterface } from "entities/messages/messages.service";
|
||||
import { createLogger } from "lib/logger";
|
||||
import { getRandomInt } from "lib/utils";
|
||||
|
||||
export class WaterMeService extends TextBasedFeature {
|
||||
export class WaterMeService {
|
||||
waterLevel: number;
|
||||
|
||||
private logger = createLogger("WaterMeService");
|
||||
|
||||
private thirsty = 3 as const;
|
||||
private enough = 10 as const;
|
||||
messagesService: MessagesServiceInterface;
|
||||
|
||||
constructor(input: TextBasedFeatureInput) {
|
||||
super(input);
|
||||
constructor(messagesService: MessagesServiceInterface) {
|
||||
this.waterLevel = 0;
|
||||
this.messagesService = messagesService;
|
||||
}
|
||||
|
||||
getReply() {
|
||||
@@ -47,7 +47,10 @@ export class WaterMeService extends TextBasedFeature {
|
||||
|
||||
async notifyIfThirsty() {
|
||||
if (this.waterLevel <= this.thirsty) {
|
||||
await this.sendMessage({ content: "ich brauche wasser :(" });
|
||||
await this.messagesService.sendToChannel(
|
||||
{ id: "channelId" },
|
||||
{ content: "ich brauche wasser :(" },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user