Other arguments in handler

More parameter decorators (e.g. @Text, @Answ, @Message, @Update, @Entity)

Example

You can also use other parameter decorators: @Text, @Message, @Update and more. Just import it from the root of the framework and call it in arguments

app.controller.ts
import { OnText, Controller, Text, Update, Message, IMessage, IUpdate } from 'nestgram';
import { AppService } from './app.service';

@Controller()
export class AppController {
  constructor(private readonly appService?: AppService) {}

  @OnText()
  async onText(
    @Text() text: string, 
    @Update() update: IUpdate, 
    @Message() message: IMessage
  ): Promise<any> {
    console.log(update, message);
    return `I got your message! ${text}`;
  }
}

All supported parameter decorators

DecoratorReturn valueDescriptionParameters

Text

string

Text of sent message

none

GetAnswer

Answer

none

Message

Sent message

none

Update

Received update

none

Entites

Entities of sent message

none

CommandParams

string[]

Command params (e.g. when user starts bot using referral link)

none

Params

any

Your params (you can edit it in middlewares)

none

Sender

User info that sent a message

none

Chat

The chat in which the message was sent

none

UserId

number

User id that sent a message

none

Entity

Entity of sent message

entity (MessageEntityTypes type)

GetLocation

Location that sent a user

none

GetVenue

Venue that sent a user

none

GetContact

Contact that sent a user

none

GetPoll

Poll that sent a user or channel, or poll that was edited

none

GetDice

Dice that sent a user

none

JoinRequest

Chat join request that sent a user

none

Last updated