Skip to content

2.5.2

Compare
Choose a tag to compare
@david-lev david-lev released this 07 Jan 21:53
· 7 commits to master since this release

What's Changed

Update with pip: pip3 install -U pywa

  • [handlers] sub-handlers ignoring flow requests with errors when call_on_error set to False
  • [handlers] fix WhatsApp.on_flow_request on class level to mark the FlowRequestHandler instance
  • [callback] callback data generic can be str
# my_handlers.py

from pywa import WhatsApp
from pywa.types import FlowRequest, FlowResponse

@WhatsApp.on_flow_request("/survey-flow")
def survey(_: WhatsApp, req: FlowRequest) -> FlowResponse:
    raise NotImplementedError(req)

@survey.on_data_exchange(call_on_error=False) # The default
def on_good_rating(_: WhatsApp, req: FlowRequest) -> FlowResponse:
    return req.respond(...)

@survey.on_data_exchange(call_on_error=True)
def on_error(_: WhatsApp, req: FlowRequest) -> None:
    logging.error("Error in survey flow: %s", req.data)
# main.py

from . import my_handlers

# register the handlers from the module
wa = WhatsApp(..., handlers_modules=[my_handlers])

Full Changelog: 2.5.1...2.5.2