如何从用户电报机器人获取信息?
How can I get information from the user telegram bot?
例如,机器人发送 "Send me your name"、"Send me your last name" 并以两种 variables.my 语言保存此数据 python 并且我使用 telepot 包来制作机器人
查看 this link。向下滚动查看示例。希望这对您有所帮助!
在 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 变量是问题 "whats your name?"
的回复关联
例如,机器人发送 "Send me your name"、"Send me your last name" 并以两种 variables.my 语言保存此数据 python 并且我使用 telepot 包来制作机器人
查看 this link。向下滚动查看示例。希望这对您有所帮助!
在 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 变量是问题 "whats your name?"
的回复关联