Controller Helper class
About controller helper that helps you with some easy tasks
Build a bot link
Sometimes you need to build a bot link (e.g. referral link to the bot). Create ControllerHelper class instance and pass Api class to it. Then call .getBotLink
method
import { OnCommand, Controller, GetApi, Api, ControllerHelper, UserId } from 'nestgram';
import { AppService } from './app.service';
@Controller()
export class AppController {
@GetApi() api: Api;
controllerHelper: ControllerHelper = new ControllerHelper(this.api);
constructor(private readonly appService?: AppService) {}
@OnCommand('start')
async start(@UserId() userId: number): Promise<string | undefined> {
const link: string | undefined = this.controllerHelper.getBotLink(userId.toString());
return link;
}
}
Last updated