danielcardeenas / whatsapp-framework

⚗️Whatsapp python api
1.16k stars 363 forks source link

Help with submenus #39

Closed maiconcosta closed 6 years ago

maiconcosta commented 6 years ago

I would like a help to make submenus, from the menu number "1" I tried using the code below but it did not work, here is my code below:

@signals.message_received.connect def handle(message):

Main menu

if message.command == "Olá":
    menuPrincipal(message)
# 1 - Budgeting
elif message.command == "1":
    orcamentos(message)
# 2 - Track an order already in progress
elif message.command == "2":
    pedidoAndamento(message)
# 3 - Change the date, time or location of the event
elif message.command == "3":
    alterarPedido(message)
# 4 - Special Offers
elif message.command == "4":
    promocoes(message)
# 5 - Speak to a representative
elif message.command == "5":
    chamarRepresentante(message)

Below is the orcamentos function that you would like to put as a submenu:

def orcamentos(message): mac.send_message(txtOrcamentos, message.conversation)

1 Party kit

if message.command == "1":
    partyKit(message)
    # 2 Confectionery cake
elif message.command == "2":
    confCake(message)
    # 3 Salty pie
elif message.command == "3":
    saltPie(message)
    # 4 Cupcakes
elif message.command == "4":
    cupcakes(message)
    # 5 Sweets
elif message.command == "5":
    sweets(message)
    # 6 Salty
elif message.command == "6":
    salty(message)
danielcardeenas commented 6 years ago

Post the stack

maiconcosta commented 6 years ago

Sorry, I do not understand.

danielcardeenas commented 6 years ago

Error messages, error stack. Whatever I can use to fix it. I need more information to understand the problem

maiconcosta commented 6 years ago

I do not get error messages, the library simply does not run the submenu.

danielcardeenas commented 6 years ago

I think you are not understanding how this works.

This: mac.send_message(txtOrcamentos, message.conversation) is an async call. It wont wait for an answer or something like that. It will just send a message and does not care about the code below.

For this to work:

# 1 Party kit
if message.command == "1":
    partyKit(message)
# 2 Confectionery cake
elif message.command == "2":
    confCake(message)
...

Needs to be handled by another @signals.message_received.connect

maiconcosta commented 6 years ago

I understand, I'm going to do tests and I'll let you know.