anote
1import { Context } from "telegraf";
2import { Keywords } from "../flows/Keywords";
3import { Command } from "./Command";
4
5export class Delete extends Command {
6async execute(): Promise<string> {
7if(!this.isValid(Keywords.DELETE)) return `Wrong sintax of ${Keywords.DELETE}`;
8const result: boolean = await this.storage.deleteFile(this.getSecondParameter());
9return result ? `Note ${this.getSecondParameter()} is deleated` : `Cant deleate note ${this.getSecondParameter()}`;
10}
11
12isValid(keyword: Keywords): boolean {
13if(
14!this.getCurrentText().startsWith(keyword) ||
15this.getCurrentText().length < 2 ||
16this.getCurrentText().split(" ").length < 2 ||
17this.getCurrentText().split(" ").length > 2
18) return false;
19return true;
20}
21}