1
import { Context } from "telegraf";
2
import { Command } from "../commands/Command";
3
import { Note } from "../types/Types";
4
import { amendKeywords, keywords } from "./Keywords";
6
export default class Parser {
9
constructor(ctx: Context){
10
this.input = new Command(ctx).getCurrentText();
20
getMessageText(): string {
24
isValidCommand(): boolean {
25
return keywords.some((keyword) => this.input.includes(keyword));
28
getStringAfterKeyword() {
29
const index: number = this.input.indexOf(' ');
30
return this.input.slice(index, this.input.length).trim();
33
getCommandName(): string {
34
return this.input.trim().split(" ")[0];
37
private getName(): string {
38
let commandName: string = '';
39
if(this.isAmendCommand()){
40
const firstSpaceIndex: number = this.input.indexOf(' ');
41
const noCommanKeyword: string = this.input.slice(firstSpaceIndex, this.input.length);
42
const secondSpaceIndex: number = noCommanKeyword.indexOf(' ');
43
commandName = noCommanKeyword.slice(0, secondSpaceIndex);
48
private isAmendCommand(): boolean {
49
return amendKeywords.some((keyword) => this.input.includes(keyword));