Skip to content

Question about the package #11

Answered by david-lev
GabrieleMassafra asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @GabrieleMassafra

I'm glad you found the package suitable for your use
If it is a number of predefined options (and which are not going to change), you can simply create some callbacks with filters for the text you want to handle:

from pywa import WhatsApp
from pywa.types import Message
from pywa.filters import text

wa = WhatsApp(...)

@wa.on_message(text.matches('hi'))
def on_hi_message(client: WhatsApp, msg: Message):
    ...

@wa.on_message(text.matches('hello'))
def on_hello_callback(client: WhatsApp, msg: Message):
    ...

Unless you want to be more dynamic, then you can do something more generic:

@wa.on_message(text)
def on_message(client: WhatsApp, msg: Message):
     match msg.t…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@GabrieleMassafra
Comment options

@david-lev
Comment options

Answer selected by GabrieleMassafra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants