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
  • Send location
  • Send live location
  • Send venue
  1. Messages

Send location (live) or venue

You can send location and live location

Send location

You can create a location using the Location class and send it using the MessageSend class-method

Location class-method take arguments:

Argument
Description
Required
1

Latitude of the location

Required

2

Longitude of the location

Required

3

Optional

app.controller.ts
import { Controller, Location, MessageSend, OnCommand } from 'nestgram';
import { AppService } from './app.service';

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

  @OnCommand('start')
  sendLocation(): MessageSend {
    return new MessageSend(new Location(33.9859004, 102.348783));
  }
}

Send live location

You can pass options to the Location class as the 3rd argument and set the live_period (meaning you are sending the live location). To edit the live location, use the Edit class-method and LiveLocation class-mark. To stop the live location, use the .stopLiveLocation API method

app.controller.ts
import {
  Answer,
  Controller,
  Edit, GetAnswer,
  Keyboard,
  KeyboardTypes,
  LiveLocation,
  Location,
  MessageSend,
  OnClick,
  OnCommand,
} from 'nestgram';

import { AppService } from './app.service';

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

  @OnCommand('start')
  sendLocation() {
    return new MessageSend(
      new Location(33.9859004, 102.348783, { live_period: 60 }), // live for 1 minute
      new Keyboard(KeyboardTypes.underTheMessage)
        .btn('Edit', 'edit').row()
        .btn('Stop', 'stop'),
    );
  }

  @OnClick('edit')
  editLocation() {
    return new Edit(new LiveLocation(33.986797, 102.347931));
  }

  @OnClick('stop')
  stopLocation(@GetAnswer() answer: Answer) {
    return answer.stopLiveLocation();
  }
}

If you want to know what arguments an API method takes, see the IDE hint

Send venue

You can also send venue - it's a location with a name. To send a venue, use Venue class-method

Venue class-method take arguments:

Argument
Description
Required
1

Latitude of the venue

Required

2

Longitude of the venue

Required

3

Title of the venue

Required

4

Address of the venue

Required

5

Optional

app.controller.ts
import { Controller, Venue, MessageSend, OnCommand } from 'nestgram';
import { AppService } from './app.service';

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

  @OnCommand('start')
  helloMessage(): MessageSend {
    return new MessageSend(
      new Venue(33.9859004, 102.348783, 'Address')
    )
  }
}
PreviousSending a media groupNextSend contact

Last updated 2 years ago

đŸ’Ŧ
Options
Options