mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-10-28 21:02:07 +03:00
feat!(): add custom execution context
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { BaseScene as Scene } from 'telegraf';
|
||||
import { ComposerMethodArgs, SceneMethods } from '../telegraf.types';
|
||||
import { UPDATE_LISTENER_METADATA } from '../telegraf.constants';
|
||||
import { ListenerMetadata } from '../interfaces';
|
||||
|
||||
export function createSceneListenerDecorator<Method extends SceneMethods>(
|
||||
method: Method,
|
||||
) {
|
||||
return (
|
||||
...args: ComposerMethodArgs<Scene<never>, Method>
|
||||
): MethodDecorator => {
|
||||
return SetMetadata(UPDATE_LISTENER_METADATA, {
|
||||
method,
|
||||
args,
|
||||
} as ListenerMetadata);
|
||||
};
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { Composer } from 'telegraf';
|
||||
import { ComposerMethodArgs, UpdateMethods } from '../telegraf.types';
|
||||
import { UPDATE_LISTENER_METADATA } from '../telegraf.constants';
|
||||
import { ListenerMetadata } from '../interfaces';
|
||||
|
||||
export function createUpdateListenerDecorator<Method extends UpdateMethods>(
|
||||
method: Method,
|
||||
) {
|
||||
return (
|
||||
...args: ComposerMethodArgs<Composer<never>, Method>
|
||||
): MethodDecorator => {
|
||||
return SetMetadata(UPDATE_LISTENER_METADATA, {
|
||||
method,
|
||||
args,
|
||||
} as ListenerMetadata);
|
||||
};
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './create-update-listener-decorator.helper';
|
||||
export * from './create-scene-listener-decorator.helper';
|
||||
5
lib/helpers/is-error-object.helper.ts
Normal file
5
lib/helpers/is-error-object.helper.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { isObject } from '@nestjs/common/utils/shared.utils';
|
||||
|
||||
export function isErrorObject(err: any): err is Error {
|
||||
return isObject(err) && !!(err as Error).message;
|
||||
}
|
||||
5
lib/helpers/is-observable.helper.ts
Normal file
5
lib/helpers/is-observable.helper.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { isFunction } from '@nestjs/common/utils/shared.utils';
|
||||
|
||||
export function isObservable(result: any): boolean {
|
||||
return result && isFunction(result.subscribe);
|
||||
}
|
||||
Reference in New Issue
Block a user