mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-01-11 14:48:10 +03:00
chore(): export more items
This commit is contained in:
parent
3e10acf070
commit
c32f2c72d9
@ -1,3 +1,3 @@
|
|||||||
export * from './tg-arguments-host.interace';
|
export * from './tg-arguments-host.interace';
|
||||||
export * from './telegraf-arguments-host';
|
export * from './telegraf-arguments-host';
|
||||||
export * from './telegraf-arguments-host';
|
export * from './telegraf-execution-context';
|
||||||
|
@ -2,5 +2,8 @@ export * from './decorators';
|
|||||||
export * from './interfaces';
|
export * from './interfaces';
|
||||||
export * from './utils';
|
export * from './utils';
|
||||||
export * from './types';
|
export * from './types';
|
||||||
|
export * from './services';
|
||||||
|
export * from './errors';
|
||||||
|
export * from './execution-context';
|
||||||
export * from './telegraf.constants';
|
export * from './telegraf.constants';
|
||||||
export * from './telegraf.module';
|
export * from './telegraf.module';
|
||||||
|
@ -131,7 +131,47 @@ export class ListenersExplorerService
|
|||||||
methodName,
|
methodName,
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: Add callback to middleware and handle return data
|
const { method, args } = metadata;
|
||||||
|
composer[method](...args, (ctx: unknown, next: Function) => {
|
||||||
|
const deferredResult = listenerCallbackFn(ctx, next);
|
||||||
|
console.log(deferredResult);
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
this.telegraf[method](
|
||||||
|
...args,
|
||||||
|
async (ctx: Context, next: () => Promise<void>) => {
|
||||||
|
const defferedResult = contextHandlerFn.call(instance, ctx, next);
|
||||||
|
const result = this.pickResult(defferedResult);
|
||||||
|
fromPromise(result)
|
||||||
|
.pipe(
|
||||||
|
mergeAll(),
|
||||||
|
filter((response: any) => !isNil(response)),
|
||||||
|
)
|
||||||
|
.subscribe((text) => {
|
||||||
|
// TODO: More processing method return logic (files, images, etc)
|
||||||
|
// Example: https://github.com/nestjs/nest/blob/01dc358aade27d3d7ca510506696aa62bfb1cc43/packages/platform-socket.io/adapters/io-adapter.ts#L56
|
||||||
|
return ctx.reply(text);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
private async pickResult(
|
||||||
|
defferedResult: Promise<any>,
|
||||||
|
): Promise<Observable<any>> {
|
||||||
|
const result = await defferedResult;
|
||||||
|
|
||||||
|
if (result && isFunction(result.subscribe)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result instanceof Promise) {
|
||||||
|
return fromPromise(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return of(result);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
createContextCallback<T extends Record<string, unknown>>(
|
createContextCallback<T extends Record<string, unknown>>(
|
||||||
|
Loading…
Reference in New Issue
Block a user