nestjs-telegraf/lib/telegraf.metadata-accessor.ts

30 lines
819 B
TypeScript
Raw Normal View History

import { Injectable } from '@nestjs/common';
2020-03-19 16:21:35 +03:00
import { Reflector } from '@nestjs/core';
import {
SCENE_METADATA,
UPDATE_LISTENER_METADATA,
2020-12-26 16:11:09 +03:00
UPDATE_METADATA,
} from './telegraf.constants';
2021-01-02 15:23:30 +03:00
import { ListenerMetadata } from './interfaces';
2020-03-19 16:21:35 +03:00
@Injectable()
export class TelegrafMetadataAccessor {
constructor(private readonly reflector: Reflector) {}
isUpdate(target: Function): boolean {
return !!this.reflector.get(UPDATE_METADATA, target);
}
isScene(target: Function): boolean {
return !!this.reflector.get(SCENE_METADATA, target);
}
getListenerMetadata(target: Function): ListenerMetadata | undefined {
return this.reflector.get(UPDATE_LISTENER_METADATA, target);
}
getSceneMetadata(target: Function): string | undefined {
return this.reflector.get(SCENE_METADATA, target);
}
2020-03-19 16:21:35 +03:00
}