Controller Helper class

About controller helper that helps you with some easy tasks

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

You can read more about Api class here

.getBotLink takes argument: run parameters for /start command (optional)

app.controller.ts
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