From 84df2d54d87f15b6ac1a65b67c893d425910371a Mon Sep 17 00:00:00 2001 From: David Lev Date: Thu, 2 Jan 2025 23:59:00 +0200 Subject: [PATCH] [version] new version! 2.5.0 --- CHANGELOG.md | 9 ++++++++- pywa/__init__.py | 2 +- pywa/handlers.py | 12 ++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ffc748..75e06db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,15 @@ > NOTE: pywa follows the [semver](https://semver.org/) versioning standard. +### 2.5.0 (2025-01-02) **Latest** -### 2.4.0 (2024-12-14) **Latest** +- [handlers] adding `on_init`, `on_data_exchange` and `on_back` decorators for flow request callback wrapper +- [flows] `FlowRequest.respond` defaults to request flow token +- [flows] adding `FlowRequest.token_no_longer_valid` shortcut +- [flows] deprecate `FlowRequest.is_health_check` and `FlowRequestActionType.PING` + + +### 2.4.0 (2024-12-14) - [sent_message] adding `SentTemplate` with `SentTemplateStatus` - [flows] adding `pattern` for `TextInput` diff --git a/pywa/__init__.py b/pywa/__init__.py index 4131c7f..a951aaf 100644 --- a/pywa/__init__.py +++ b/pywa/__init__.py @@ -9,6 +9,6 @@ from pywa.client import WhatsApp from pywa.utils import Version -__version__ = "2.4.0" +__version__ = "2.5.0" __author__ = "David Lev" __license__ = "MIT" diff --git a/pywa/handlers.py b/pywa/handlers.py index 979367a..26f9e8a 100644 --- a/pywa/handlers.py +++ b/pywa/handlers.py @@ -604,7 +604,7 @@ def on( Args: action: The action type to listen to. - screen: The screen ID to listen to (if screen is not provided, the handler will be called for all screens for this action!). + screen: The screen to listen to (if screen is not provided, the handler will be called for all screens for this action!). filters: A filter function to apply to the incoming request. Returns: @@ -625,7 +625,7 @@ def on_init( """ Decorator to add a handler for the :class:`FlowRequestActionType.INIT` action. - - This request arrives when the flow **sent** with action type of :class:`FlowRequestActionType.DATA_EXCHANGE`. + - This request arrives when the :class:`~pywa.types.callback.FlowButton` sent with action_type of :class:`FlowRequestActionType.DATA_EXCHANGE`. Example: @@ -691,11 +691,11 @@ def on_data_exchange( ... ... >>> @feedback_flow_handler.on_data_exchange(screen="SURVEY", filters=filters.new(lambda _, r: r.data["rating"] == "5")) - >>> def on_data_exchange(_: WhatsApp, req: FlowRequest) -> FlowResponse: + >>> def on_survey_with_rating_5(_: WhatsApp, req: FlowRequest) -> FlowResponse: ... return req.respond(...) Args: - screen: The screen ID to listen to (if screen is not provided, the handler will be called for all screens for this action!). + screen: The screen to listen to (if screen is not provided, the handler will be called for all screens for this action!). filters: A filter function to apply to the incoming request. call_on_error: Whether to call the handler when the request has an error (The return value of the callback will be ignored). @@ -731,7 +731,7 @@ def on_back( """ Decorator to add a handler for the :class:`FlowRequestActionType.BACK` action. - - This request arrives when the user clicks the back button in the WhatsApp client and the flows screen's ``refresh_on_back`` is set to ``True``. + - This request arrives when the user clicks the back button in the WhatsApp client and the flows screen ``refresh_on_back`` is set to ``True``. - This callback must return a :class:`~pywa.types.flows.FlowResponse` object, a :class:`dict` or to raise :class:`~pywa.types.flows.FlowResponseError` subclass. Example: @@ -747,7 +747,7 @@ def on_back( ... return req.respond(...) Args: - screen: The screen ID to listen to (if screen is not provided, the handler will be called for all screens for this action!). + screen: The screen to listen to (if screen is not provided, the handler will be called for all screens for this action!). filters: A filter function to apply to the incoming request. Returns: