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
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
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();
  }
}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
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')
    )
  }
}Last updated