用于在 Telegram bot、python 中检查正则表达式消息的正确 while 循环

问题描述

在我使用 python 和电报机器人的第一步时,我完全迷失了正确的 while 循环,以检查消息是否符合正则表达式类型。问题出在“def check_A”块中。我假设我的核心问题 - 我没有逻辑(> 语法) bot 应该如何处理新消息后收到错误的消息作为开始日期

def start_message(message):
    bot.send_message(message.chat.id,'Type start date dd/mm/yyyy')
    bot.register_next_step_handler(message,check_A)
def check_A(message):
    match_A=re.fullmatch('\d\d\D\d\d\D\d\d\d\d',message.text)
    while bool(match_A) == False:
        bot.send_message(message.chat.id,'Type correctly')
        ?
        ?
    bot.register_next_step_handler(message,get_A)
def get_A(message):
    global A;
    A = message.text;
    A=time.mktime(datetime.datetime.strptime(A,"%d/%m/%Y").timetuple()) - 86400
    bot.send_message(message.from_user.id,'Type end date dd/mm/yyyy');
    bot.register_next_step_handler(message,get_B);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)