簡體   English   中英

如何通過 Telepot 在機器人電報中獲取用戶的位置和地點

[英]How to get users's location and Venue in a bot telegram by telepot

我正在為公交車行程創建一個帶有 Python Telepot 的機器人。 我不明白如何管理命令,誰能向我解釋如何獲得使用我的機器人的用戶的 position(街道名稱)?

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)

您沒有向我們展示為返回的msg響應打印的 output。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM