Skip to content

Commit

Permalink
[docs] remove deprecated filters
Browse files Browse the repository at this point in the history
  • Loading branch information
david-lev committed Apr 30, 2024
1 parent 67d73cb commit 762c619
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 22 deletions.
9 changes: 4 additions & 5 deletions docs/source/content/examples/demo-bots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ This is a simple bot that uploads files from URLs.
verify_token='xyzxyz',
)
@wa.on_message(filters.text.startswith('http'))
@wa.on_message(filters.startswith('http'))
def download(_: WhatsApp, msg: Message):
msg.reply_document(msg.text, filename=msg.text.split('/')[-1])
Expand Down Expand Up @@ -118,9 +118,8 @@ Usage:
import re
import flask # pip3 install flask
from pywa import WhatsApp
from pywa import WhatsApp, filters
from pywa.types import Message
from pywa.filters import text
flask_app = flask.Flask(__name__)
Expand All @@ -133,7 +132,7 @@ Usage:
pattern = re.compile(r'^(\d+)\s*([+*/-])\s*(\d+)$')
@wa.on_message(text.regex(pattern))
@wa.on_message(filters.regex(pattern))
def calculator(_: WhatsApp, msg: Message):
a, op, b = re.match(pattern, msg.text).groups()
a, b = int(a), int(b)
Expand Down Expand Up @@ -235,7 +234,7 @@ A simple WhatsApp bot that translates text messages to other languages.
# Save the message ID so we can use it later to get the original text.
MESSAGE_ID_TO_TEXT[msg_id] = msg.text
@wa.on_callback_selection(filters.callback.data_startswith('translate:'))
@wa.on_callback_selection(filters.startswith('translate:'))
def translate(_: WhatsApp, sel: CallbackSelection):
lang_code = sel.data.split(':')[-1]
try:
Expand Down
11 changes: 0 additions & 11 deletions docs/source/content/filters/callback_filters.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/source/content/filters/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,5 @@ Built-in Filters

./common_filters
./message_filters
./callback_filters
./message_status_filters
./template_status_filters
10 changes: 5 additions & 5 deletions pywa/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class CallbackButtonHandler(Handler):
>>> from pywa import WhatsApp, filters as fil
>>> wa = WhatsApp(...)
>>> print_btn = lambda _, btn: print(btn)
>>> wa.add_handlers(CallbackButtonHandler(print_btn, fil.callback.data_startswith('id:')))
>>> wa.add_handlers(CallbackButtonHandler(print_btn, fil.startswith('id:')))
Args:
callback: The callback function (gets the WhatsApp instance and the callback as arguments)
Expand Down Expand Up @@ -324,7 +324,7 @@ class CallbackSelectionHandler(Handler):
>>> from pywa import WhatsApp, filters as fil
>>> wa = WhatsApp(...)
>>> print_selection = lambda _, sel: print(sel)
>>> wa.add_handlers(CallbackSelectionHandler(print_selection, fil.callback.data_startswith('id:')))
>>> wa.add_handlers(CallbackSelectionHandler(print_selection, fil.startswith('id:')))
Args:
callback: The callback function. (Takes a :class:`pywa.WhatsApp` instance and a
Expand Down Expand Up @@ -635,7 +635,7 @@ def on_message(
>>> from pywa.types import Button
>>> from pywa import filters as fil
>>> wa = WhatsApp(...)
>>> @wa.on_message(fil.text.matches("Hello", "Hi", ignore_case=True))
>>> @wa.on_message(fil.matches("Hello", "Hi", ignore_case=True))
... def hello_handler(_: WhatsApp, msg: Message):
... msg.react("👋")
... msg.reply_text(text="Hello from PyWa!", quote=True, buttons=[Button("Help", data="help")
Expand Down Expand Up @@ -673,7 +673,7 @@ def on_callback_button(
>>> from pywa.types import CallbackButton
>>> from pywa import filters as fil
>>> wa = WhatsApp(...)
>>> @wa.on_callback_button(fil.callback.data_matches("help"))
>>> @wa.on_callback_button(fil.matches("help"))
... def help_handler(_: WhatsApp, btn: CallbackButton):
... btn.reply_text(text="What can I help you with?")
Expand Down Expand Up @@ -721,7 +721,7 @@ def on_callback_selection(
>>> from pywa.types import CallbackSelection
>>> from pywa import filters as fil
>>> wa = WhatsApp(...)
>>> @wa.on_callback_selection(fil.callback.data_startswith("id:"))
>>> @wa.on_callback_selection(fil.startswith("id:"))
... def id_handler(_: WhatsApp, sel: CallbackSelection):
... sel.reply_text(text=f"Your ID is {sel.data.split(':', 1)[1]}")
Expand Down

0 comments on commit 762c619

Please sign in to comment.