![](/img/trans.png)
[英]How can i store input from a user using my telegram bot and then fetch the input when i want
[英]How can I get information from the user telegram bot?
例如,机器人发送“给我你的名字”,“给我你的姓氏”并将这些数据保存在两个变量中。我的语言是 python,我使用 Telepot 包来制作机器人
看看这个链接。 向下滚动查看示例。 希望这有帮助!
在 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 变量是问题“你叫什么名字?”的回复助理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.