Skip to content

Commit

Permalink
[docs] improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
david-lev committed Jan 11, 2025
1 parent 902a639 commit bea0daa
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 72 deletions.
7 changes: 4 additions & 3 deletions docs/source/content/flows/flow_json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ Here you will find all the components that make up a Flow JSON object.

.. autoclass:: Form()

.. automethod:: FormComponent.ref

.. automethod:: FormComponent.ref_in
.. autoclass:: FormComponent
:members: ref, ref_in

.. autoclass:: TextHeading()

Expand Down Expand Up @@ -104,6 +103,8 @@ Here you will find all the components that make up a Flow JSON object.

.. autoclass:: NextType()

.. autoclass:: FlowStr()

.. autoclass:: ScreenDataRef()

.. autoclass:: ComponentRef()
Expand Down
8 changes: 8 additions & 0 deletions docs/source/content/flows/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ Every component on the FlowJSON has a corresponding class in :mod:`pywa.types.fl
:class:`CompleteAction`,
:class:`UpdateDataAction`,
:class:`OpenUrlAction`
* - Helpers
- :class:`ScreenData`,
:class:`ScreenDataUpdate`,
:class:`ScreenDataRef`,
:class:`ComponentRef`,
:class:`FlowStr`,
:class:`Condition`,
:class:`MathExpression`

==================

Expand Down
10 changes: 7 additions & 3 deletions docs/source/content/listeners/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ Let's see an example of how to use a listener:
msg.reply("Hello! How old are you?")
age: types.Message = client.listen( # Now we want to wait for the user to send their age
to=msg.sender,
filters=filters.text
filters=filters.message & filters.text # We only want to listen for `Message` updates that contain text
)
msg.reply(f"Your age is {age.text}.")
In the example above, we are waiting for the user to send their age. The `client.listen` method will wait for the user to send a message that matches the filter :attr:`pywa.filters.text`.

.. tip::

You can use one of the `shortcuts <#id1>`_ in order to create a listener when sending a message. For example, you can use the :meth:`~pywa.types.sent_message.SentMessage.wait_for_reply` method to create a listener that waits for a *Message* reply from the user.

Cancel
______

Expand All @@ -49,7 +53,7 @@ Now, listeners have a few options that you can use to customize the behavior. fo
)
age = client.listen(
to=msg.sender,
filters=filters.text,
filters=filters.message & filters.text,
timeout=20, # 20 seconds
# If the user presses "cancel" the listener will be canceled
cancelers=filters.callback_button & filters.matches("cancel")
Expand Down Expand Up @@ -79,7 +83,7 @@ You can also handle listener exceptions. For example, you can handle the case wh
try:
age = client.listen(
to=msg.sender,
filters=filters.text,
filters=filters.message & filters.text,
cancelers=filters.callback_button & filters.matches("cancel"),
timeout=20
)
Expand Down
Loading

0 comments on commit bea0daa

Please sign in to comment.