nestjs-telegraf/lib/execution-context/telegraf-arguments-host.ts

23 lines
654 B
TypeScript
Raw Normal View History

2021-01-03 01:30:57 +03:00
import { ArgumentsHost } from '@nestjs/common';
import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context-host';
import { TgArgumentsHost } from './tg-arguments-host.interface';
2021-01-03 01:30:57 +03:00
export class TelegrafArgumentsHost
extends ExecutionContextHost
implements TgArgumentsHost {
static create(context: ArgumentsHost): TelegrafArgumentsHost {
const type = context.getType();
const tgContext = new TelegrafArgumentsHost(context.getArgs());
tgContext.setType(type);
return tgContext;
}
getContext<T = any>(): T {
return this.getArgByIndex(0);
}
getNext<T = any>(): T {
return this.getArgByIndex(1);
}
}