2020-12-25 23:11:16 +03:00
|
|
|
import { Injectable } from '@nestjs/common';
|
2020-03-19 16:21:35 +03:00
|
|
|
import { Reflector } from '@nestjs/core';
|
2020-03-19 18:20:07 +03:00
|
|
|
import {
|
2020-12-26 23:19:30 +03:00
|
|
|
UPDATE_LISTENER_METHOD_METADATA,
|
2020-12-26 16:11:09 +03:00
|
|
|
UPDATE_METADATA,
|
2020-12-26 16:24:38 +03:00
|
|
|
UPDATE_LISTENER_OPTIONS_METADATA,
|
2020-12-25 23:11:16 +03:00
|
|
|
} from './telegraf.constants';
|
2020-12-26 23:19:30 +03:00
|
|
|
import { ListenerMethod } from './enums';
|
2020-03-19 16:21:35 +03:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class TelegrafMetadataAccessor {
|
|
|
|
constructor(private readonly reflector: Reflector) {}
|
|
|
|
|
2020-12-26 14:54:10 +03:00
|
|
|
isUpdate(target: Function): boolean {
|
2020-12-26 23:19:30 +03:00
|
|
|
return !!this.reflector.get(UPDATE_METADATA, target);
|
2020-12-26 14:54:10 +03:00
|
|
|
}
|
|
|
|
|
2020-12-26 23:19:30 +03:00
|
|
|
getListenerMethod(target: Function): ListenerMethod | undefined {
|
|
|
|
return this.reflector.get(UPDATE_LISTENER_METHOD_METADATA, target);
|
2020-09-09 22:46:25 +03:00
|
|
|
}
|
|
|
|
|
2020-12-26 23:19:30 +03:00
|
|
|
getListenerOptions(target: Function): unknown[] {
|
|
|
|
return this.reflector.get(UPDATE_LISTENER_OPTIONS_METADATA, target) || [];
|
2020-03-19 17:28:56 +03:00
|
|
|
}
|
2020-03-19 16:21:35 +03:00
|
|
|
}
|