anote
1import { Context } from "telegraf";
2import { Keywords } from "../flows/Keywords";
3import Saver from "../service/Saver";
4import { ICommand } from "../types/Types";
5
6export class Command implements ICommand {
7storage: Saver = new Saver();
8ctx: Context;
9
10constructor(ctx: Context){
11this.ctx = ctx;
12}
13
14async execute(): Promise<string | null> {
15return 'Smth wrong';
16}
17
18isValid(keyword: Keywords): boolean {
19if(!this.getCurrentText().startsWith(keyword) || this.getCurrentText().length < 2) return false;
20return true;
21}
22
23getTail(): string {
24if(!this.getCurrentText().trim().includes(' ')) return '/';
25return this.getCurrentText().trim().split(' ')[1];
26}
27
28getSecondParameter(): string {
29return this.getTail().split(' ')[0];
30}
31
32getCurrentText(): string {
33const update: any = this.ctx.update;
34return update.message.text;
35}
36
37getPath(): string {
38const lastIndex = this.getTail().lastIndexOf("/");
39return this.getTail().substring(0, lastIndex);
40}
41}