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
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
Decorator
Return value
Description
Parameters
Text
string
Text 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
UserId
number
User id that sent a message
none
Last updated