在Telegram Bot上处理多个用户互动

时间:2018-09-17 01:26:09

标签: python-3.x python-requests telegram telegram-bot python-telegram-bot

我一直在用Python编写电报机器人。直到2个用户同时与聊天机器人开始对话,然后一个对话被另一个对话打断为止,它一直运行良好。我该如何解决?这是我的代码(一个订购披萨的聊天机器人):https://github.com/CYBONYMOUS/pizza_chat_bot/blob/master/telegram_bot.py

但是我将在此处粘贴一段代码:

def start():
    Total = 0
    time = 0
    last_update_id = get_last_update_id(get_updates())
    text, name, chat =get_last_chat_id_and_text(get_updates(last_update_id))
    if(text=="/start" or text=="/start foo"):
        send_message(chat,"Welcome to Happy Pizza , {}".format(name))
        send_message(chat,"Thank you for making the choice to interact with Happy Pizza ")
        options = ["Place an Order", "Leave a Comment", "Lodge a Complaint", "Display Special Offers", "Check Out/ Exit"]
        send_message(chat,"What would you like to do?", 
        reply_markup_maker(options))
        text, name,chat=get_last_chat_id_and_text(get_updates(last_update_id))
        while(text == "/start"):
            text, name, chat = get_last_chat_id_and_text(get_updates(last_update_id))
            sleep(0.5)

            if(text == "Place An Order"):
                place_order(chat,Total,time, last_update_id)

            if(text =="Leave A Comment"):
                leave_comment(chat, text, last_update_id)

            if(text == "Lodge A Complaint"):
                lodge_complaint(chat, text, last_update_id)

            if(text == "Check Out/ Exit"):
                check_out_or_exit(chat, Total, time)

            if(text == "Display Special Offers"):
                display_promotions(chat)

谢谢。

0 个答案:

没有答案