py-telegram-bot-api - PyTelegramBot API:直接在文本命令上获取用户位置
问题描述
这是我的代码:
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 或类似的东西时获取用户位置。
不幸的是,当我这样做时,该位置不会随消息一起发送。即使在文本命令上,我也能做些什么来获取位置。
解决方案
推荐阅读
- python - 在带有多个双引号的字段内读取带有分隔符的 csv 文件
- wordpress - 我的 WordPress 网站遇到了致命错误:未捕获的错误:调用未定义的方法 WP_Site_Health::get_instance()
- google-sheets - 表格 - 使用 3 个条件(包括变量)进行查找
- ios - 有什么方法可以在没有材料主题的情况下在 Swift 中从 MDCChipField 更改芯片背景颜色?
- javascript - 无法使用 ng-container Angular 9 Flex 布局读取未定义 fxFlex 问题的属性“setProperty”
- android - 如果已经有一个“等待”处于活动状态,则应用程序崩溃
- firebase - 如何创建与现有结构相同的firebase项目?
- sql - 计算一个人在一小时内出现了多少次
- java - Android Studio 日历查看标记日期
- go - 如何打破 Golang 中的循环