2020-03-19 16:21:35 +03:00
|
|
|
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) {}
|
|
|
|
|
2020-03-19 16:34:44 +03:00
|
|
|
isTelegrafUse(target: Type<any> | Function): boolean {
|
|
|
|
if (!target) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !!this.reflector.get(DECORATORS.USE, target);
|
|
|
|
}
|
|
|
|
|
2020-03-19 16:21:35 +03:00
|
|
|
isTelegrafOn(target: Type<any> | Function): boolean {
|
|
|
|
if (!target) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !!this.reflector.get(DECORATORS.ON, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
getTelegrafOnMetadata(target: Type<any> | Function) {
|
|
|
|
return this.reflector.get(DECORATORS.ON, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
isTelegrafHears(target: Type<any> | Function): boolean {
|
|
|
|
if (!target) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !!this.reflector.get(DECORATORS.HEARS, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
getTelegrafHearsMetadata(target: Type<any> | Function) {
|
|
|
|
return this.reflector.get(DECORATORS.HEARS, target);
|
|
|
|
}
|
2020-03-19 16:39:47 +03:00
|
|
|
|
|
|
|
isTelegrafCommand(target: Type<any> | Function): boolean {
|
|
|
|
if (!target) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !!this.reflector.get(DECORATORS.COMMAND, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
getTelegrafCommandMetadata(target: Type<any> | Function) {
|
|
|
|
return this.reflector.get(DECORATORS.COMMAND, target);
|
|
|
|
}
|
2020-03-19 16:44:05 +03:00
|
|
|
|
|
|
|
isTelegrafStart(target: Type<any> | Function): boolean {
|
|
|
|
if (!target) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !!this.reflector.get(DECORATORS.START, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
isTelegrafHelp(target: Type<any> | Function): boolean {
|
|
|
|
if (!target) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !!this.reflector.get(DECORATORS.HELP, target);
|
|
|
|
}
|
2020-03-19 16:46:31 +03:00
|
|
|
|
|
|
|
isTelegrafSettings(target: Type<any> | Function): boolean {
|
|
|
|
if (!target) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !!this.reflector.get(DECORATORS.SETTINGS, target);
|
|
|
|
}
|
2020-03-19 16:54:34 +03:00
|
|
|
|
|
|
|
isTelegrafEntity(target: Type<any> | Function): boolean {
|
|
|
|
if (!target) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !!this.reflector.get(DECORATORS.ENTITY, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
getTelegrafEntityMetadata(target: Type<any> | Function) {
|
|
|
|
return this.reflector.get(DECORATORS.ENTITY, target);
|
|
|
|
}
|
2020-03-19 16:58:27 +03:00
|
|
|
|
|
|
|
isTelegrafMention(target: Type<any> | Function): boolean {
|
|
|
|
if (!target) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !!this.reflector.get(DECORATORS.MENTION, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
getTelegrafMentionMetadata(target: Type<any> | Function) {
|
|
|
|
return this.reflector.get(DECORATORS.MENTION, target);
|
|
|
|
}
|
2020-03-19 17:02:37 +03:00
|
|
|
|
|
|
|
isTelegrafPhone(target: Type<any> | Function): boolean {
|
|
|
|
if (!target) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !!this.reflector.get(DECORATORS.PHONE, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
getTelegrafPhoneMetadata(target: Type<any> | Function) {
|
|
|
|
return this.reflector.get(DECORATORS.PHONE, target);
|
|
|
|
}
|
2020-03-19 16:21:35 +03:00
|
|
|
}
|