import { Injectable, Type } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; import { TelegrafStart } from './decorators'; import { DECORATORS } from './telegraf.constants'; @Injectable() export class TelegrafMetadataAccessor { constructor(private readonly reflector: Reflector) {} isTelegrafUse(target: Type | Function): boolean { if (!target) { return false; } return !!this.reflector.get(DECORATORS.USE, target); } isTelegrafStart(target: Type | Function): boolean { if (!target) { return false; } return !!this.reflector.get(DECORATORS.START, target); } isTelegrafOn(target: Type | Function): boolean { if (!target) { return false; } return !!this.reflector.get(DECORATORS.ON, target); } getTelegrafOnMetadata(target: Type | Function) { return this.reflector.get(DECORATORS.ON, target); } isTelegrafHears(target: Type | Function): boolean { if (!target) { return false; } return !!this.reflector.get(DECORATORS.HEARS, target); } getTelegrafHearsMetadata(target: Type | Function) { return this.reflector.get(DECORATORS.HEARS, target); } }