Nestgram
  • ⭐About Nestgram
  • 📄Guide
  • 📰News
  • đŸ”ŧHandling updates
    • Handling commands
    • Handling text messages
    • Handling other updates
    • Entities: url, email and other
    • Other arguments in handler
    • Handling media files and download it
  • đŸĒļNestgram Features
    • Services
    • Middlewares and Params
    • Sending messages correctly
    • Answer class
    • Scopes
    • States
    • Views
  • đŸ’ŦMessages
    • Sending a photo, video and other media
    • Sending a media group
    • Send location (live) or venue
    • Send contact
    • Send poll
    • Send dice
    • Edit/delete messages
    • Copy or Forward a message
  • âŒ¨ī¸Keyboards
    • Keyboard types, building keyboard
    • Handle underTheMessage keyboard button click by Alert or Toast
    • Keyboard layouts
  • âš™ī¸Config
    • CLI
    • Webhooks and run config
    • Api class
    • Modules
      • Mongo module
    • Controller Helper class
  • 🤖API Reference
    • Set chat action
    • Save user profile photo
    • Ban, unban user or chat
    • Restrict or Promote user
    • Set chat permissions
    • Set chat admin custom title
    • Chat invite links
    • Join requests
    • Update chat info, photo, title, description and more
    • Pin or unpin messages
    • Get chat info, leave chat
    • Check user subscription
    • Chat sticker set
    • My commands
    • My default admin rights
    • Menu button
Powered by GitBook
On this page
  • Example
  • All supported parameter decorators
  1. Handling updates

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

Decorator
Return value
Description
Parameters

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

PreviousEntities: url, email and otherNextHandling media files and download it

Last updated 2 years ago

[]

đŸ”ŧ
Answer
IMessage
IUpdate
IMessageEntity
IUser
IChat
IMessageEntity
ILocation
IVenue
IContact
IPoll
IDice
IChatJoinRequest