首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过telepot获取机器人报文中用户的位置和地点

如何通过telepot获取机器人报文中用户的位置和地点
EN

Stack Overflow用户
提问于 2020-04-19 03:50:16
回答 1查看 340关注 0票数 0

我正在创建一个使用Python telepot的机器人,用于公交路线。我不知道如何管理命令,有谁能告诉我如何获取使用我的机器人的用户的位置(街道名称)?

代码语言:javascript
复制
import json
import time
from pprint import pprint
import telepot
from telepot.loop import MessageLoop
import telepot.namedtuple
bot = telepot.Bot("token")
lista = ["New York","Los Angeles","Miami","Toronto","Berlin","Rome"]
seq = iter(lista)
keyboard = {"keyboard": [[{"text": i} for i in pair] for pair in zip(seq)]}
def handle(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)
    print(content_type, chat_type, chat_id)

    if content_type == "text":
        bot.sendMessage(chat_id, msg["text"], reply_markup=keyboard)
        bot.editMessageLiveLocation(latitude, longitude) #i've tried here but nothing




MessageLoop(bot, handle).run_as_thread()
while 1:
    time.sleep(10)
EN

回答 1

Stack Overflow用户

发布于 2020-04-19 04:26:44

您没有向我们显示返回的msg响应的打印输出。

if中,第一行是有意义的,它符合https://telepot.readthedocs.io/en/latest/reference.html#telepot.Bot.sendMessage

第二行没有什么意义,它没有传递https://telepot.readthedocs.io/en/latest/reference.html#telepot.Bot.editMessageLiveLocation解释的你需要的参数。我看不到msg_identifier

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61295323

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档