Python 如何从用户电报机器人获取信息?

Python 如何从用户电报机器人获取信息?,python,bots,telegram,telepot,Python,Bots,Telegram,Telepot,例如,bot发送“Send me your name”、“Send me your last name”并将此数据保存在两个变量中。我的语言是python,我使用telepot包创建bot签出链接。向下滚动查看示例。希望这有帮助 在telepot软件包中: import telepot from telepot.loop import MessageLoop import time bot = telepot.Bot('my_token') def handle(msg): conten

例如,bot发送“Send me your name”、“Send me your last name”并将此数据保存在两个变量中。我的语言是python,我使用telepot包创建bot签出链接。向下滚动查看示例。希望这有帮助

在telepot软件包中:

import telepot
from telepot.loop import MessageLoop
import time
bot = telepot.Bot('my_token')
def handle(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)
    send1 = bot.sendMessage(chat_id,'whats your name?')
    if send1:
        text1 = msg['text']
        print(text1)


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

text1变量是问题“你叫什么名字?”

请查看此链接,谢谢。你在这个模块中有一个简单的例子吗?我没有使用这个模块如果你在链接中向下滚动,我会看到这些例子。这些例子使用日志模块,因为我的python版本是3.4,我不能使用日志模块。谢谢,我搜索了谷歌,找到了另一个不使用日志模块的例子。我使用telegram.ext,得到了回复。请回答,我投你一票