Как узнать местоположение пользователя и место в бот-телеграмме по telepot - PullRequest
0 голосов
/ 18 апреля 2020

Я создаю бота с Python телепотом для автобусных маршрутов. Я не понимаю, как управлять командами, может кто-нибудь объяснить мне, как я могу получить позицию (название улицы) пользователя, который использует мой бот?

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)

1 Ответ

0 голосов
/ 18 апреля 2020

Вы не показали нам напечатанный вывод для ответа msg, который вернулся.

В пределах if 1-я строка имеет смысл, она соответствует https://telepot.readthedocs.io/en/latest/reference.html#telepot .Bot .sendMessage .

2-я строка не имеет смысла, она не передает параметры, которые https://telepot.readthedocs.io/en/latest/reference.html#telepot .Bot.editMessageLiveLocation объясняет, что вам нужно. Я не вижу msg_identifier.

...