这是我的代码:
import os
import telebot
API_KEY = os.environ['API_KEY']
bot = telebot.TeleBot(API_KEY)
@bot.message_handler(commands=['LOCATEME'],content_types=['location','text'])
def handle_location(message):
bot.reply_to(text = "{0}, {1}".format(message.location.latitude, message.location.longitude),message=message)
bot.polling()
现在这有效,当 content_types 为 ['location'] 时,但我也想在他们发送命令 /LOCATEME 或类似的东西时获取用户位置。
不幸的是,当我这样做时,该位置不会随消息一起发送。即使在文本命令上,我也能做些什么来获取位置。