M
M
MuzzDead2022-02-21 00:20:58
Python
MuzzDead, 2022-02-21 00:20:58

How to copy the geolocation in telegram (which was sent to the bot) as a link to Google Maps / geolocation?

import telebot
from telebot import types

bot = telebot.TeleBot('5119846546:AAFxQuiyo1n0xeaxQtSGyq52JhC5bkMtP9k')

@bot.message_handler(commands=["start"])
def start(message): #Keyboard
with button to request location
chatid = message.chat.id
keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)
button_geo = types.KeyboardButton(text="Send Geolocation", request_location=True)
keyboard.add(button_geo)
bot.send_message(chatid, "Need help?", reply_markup =keyboard) #Get

location
@bot.message_handler(content_types=['location'])
def location(message):
if message.location is not None:
print(message.location)
bot.send_message('chat_id',message.location) #send this location to a specific contact
# print(message)

# def cmd_start(message):
# bot.send_message(message.from_user.id, 'Hello'

bot.polling() input
()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2022-02-21
@MuzzDead

Literally send_location is the name of the method. Three required parameters - chat id, latitude, longitude

bot.send_location(chatid, message.location.latitude, message.location.longitude)

https://core.telegram.org/bots/api#sendlocation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question