I'm creating a bot with Python telepot for the bus itineraries. I don't understand how to manage commands, can anyone explain to me how I can get the position (street name) of a user who uses my bot?
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)
You didn't show us printed output for the msg
response that came back.
Within the if
, the 1st line makes sense, it conforms to https://telepot.readthedocs.io/en/latest/reference.html#telepot.Bot.sendMessage .
The 2nd line makes little sense, it does not pass in the parameters that https://telepot.readthedocs.io/en/latest/reference.html#telepot.Bot.editMessageLiveLocation explains you need. I see no msg_identifier
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.