2020-03-19 16:54:34 +03:00
|
|
|
import { SetMetadata } from '@nestjs/common';
|
|
|
|
import { DECORATORS } from '../telegraf.constants';
|
|
|
|
|
2020-03-19 18:20:07 +03:00
|
|
|
export type TelegrafEntityEntity =
|
|
|
|
| string
|
|
|
|
| string[]
|
|
|
|
| RegExp
|
|
|
|
| RegExp[]
|
|
|
|
| Function;
|
|
|
|
|
|
|
|
export interface TelegrafEntityMetadata {
|
|
|
|
entity: TelegrafEntityEntity;
|
|
|
|
}
|
2020-03-19 16:54:34 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Entity handling.
|
|
|
|
* @param entity Entity name
|
|
|
|
*
|
|
|
|
* https://telegraf.js.org/#/?id=entity
|
|
|
|
*/
|
2020-03-19 18:20:07 +03:00
|
|
|
export function TelegrafEntity(entity: TelegrafEntityEntity): MethodDecorator {
|
2020-03-19 16:54:34 +03:00
|
|
|
return SetMetadata(DECORATORS.ENTITY, { entity });
|
|
|
|
}
|