【发布时间】:2017-06-19 21:02:44
【问题描述】:
下面的代码是一个Telegram Bot,它基本上需要一个人username和password并验证它以提供他的平均支出。
我们看到的问题是机器人等待用户发送他的用户名和密码 10 秒 要么浪费时间(或)没有足够的时间。我该如何编程,让机器人等待用户消息,然后执行下一行(等到触发器)
def highest(intent,chatid,text):
seq=["What is your Username ?","Password?"]
send_message(seq[0],chatid)
time.sleep(6)
name,chatid = reply_function()
print name
send_message(seq[1],chatid)
time.sleep(6)
pw,chatid = reply_function()
print pw
try:
flag = obj.validate(name,pw)
if flag=="Verified":
for i in obj.avg_transactions():
send_message(i,chatid)
else:
send_message("try again",chatid)
highest(intent,chatid,text)
except:
send_message("try again",chatid)
highest(intent,chatid,text)
【问题讨论】:
标签: python python-2.7 telegram telegram-bot python-telegram-bot