Skip to content

Releases: david-lev/pywa

1.9.0

25 Oct 18:31
Compare
Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

  • [handlers] call .stop_handling() on every update if you want to stop handling the update (or raise pywa.types.StopHandling)
  • [errors] include requests.Response with all api errors
  • [client] mark keyboard argument in .send_message as deprecated. use buttons instead
from pywa import WhatsApp, filters as fil, types

wa = WhatsApp(...)

@wa.on_message(fil.text)
def print_msg_1(_: WhatsApp, msg: types.Message):
    print(msg)
    msg.stop_handling()  # Stop handling the message
    # or raise types.StopHandling

@wa.on_message(fil.text)
def print_msg_2(_: WhatsApp, msg: types.Message):
    print("This handler will never be called")

Full Changelog: 1.8.0...1.9.0

1.8.0

19 Oct 22:47
Compare
Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

See Handlers for more information.

from pywa import WhatsApp
from flask import Flask
from pywa.types import Message, CallbackButton, Button
from pywa.filters import text, callback

flask_app = Flask(__name__)
wa = WhatsApp(
    phone_id='1234567890',
    token='xxxxxxx',
    server=flask_app,
    callback_url='https://6b3e-18.ngrok.io',
    verify_token='XYZ123',
    app_id=123456,
    app_secret='yyyyyy'
)

# register the handlers

flask_app.run()  # Run the flask app to start the server

Full Changelog: 1.7.3...1.8.0

1.7.3

18 Oct 21:18
Compare
Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

  • callback: Treat the Template's QuickReplyButtonData as an incoming CallbackButton (Reported by @bcombes in #17)
  • handlers: adding @functools.wraps to all on_x decorators to preserve callbacks metadata

Full Changelog: 1.7.2...1.7.3

1.7.2

12 Oct 23:45
Compare
Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

  • reply to CallbackButton.id instead of to .reply_to_message by @yehuda-lev in #16
  • change default CallbackData separators to unused characters ( for clb sep, ~ for data sep and § for True boolean

Full Changelog: 1.7.1...1.7.2

1.7.1

12 Oct 22:42
Compare
Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

callback: hot-fix for last booleans fields on CallbackData (WhatsApp Cloud API consider "1: " and "1:" as duplicate datas)

Full Changelog: 1.7.0...1.7.1

1.7.0

12 Oct 18:43
Compare
Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

types: new ButtonUrl type
client: allowing to provide mime_type when sending media as bytes, open file or file path without extensions

from pywa import WhatsApp
from pywa.types import ButtonUrl

wa = WhatsApp(...)

wa.send_message(
    text='Hi',
    to='972123456789',
    keyboard=ButtonUrl(title='Google Search', url='https://google.com')
)

Full Changelog: 1.6.0...1.7.0

1.6.0

11 Oct 11:58
Compare
Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

  • handlers: apply callback data factory before filters by setting factory_before_filters to True when registering the handler
import dataclasses
from pywa import WhatsApp
from pywa.types import CallbackData, CallbackButton

@dataclasses.dataclass(frozen=True, slots=True)
class User(CallbackData):
    id: int
    admin: bool

wa = WhatsApp(...)

@wa.on_callback_button(
    lambda _, b: b.data.admin, lambda _, b: b.data.id == 1, # filters get access to user data
    factory=User, # factory to convert the callback data to the user object
    factory_before_filters=True # factory will run before the filters
)
def on_callback_button(_: WhatsApp, clb: CallbackButton[User]):
    print(f"User with id {clb.data.id} is admin")

Full Changelog: 1.5.4...1.6.0

1.5.4

08 Oct 20:36
Compare
Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

  • template: fix media key

Full Changelog: 1.5.3...1.5.4

1.5.3

03 Oct 19:31
Compare
Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

  • webhook: faster field-to-handler matching
  • message_status: make .pricing_model optional

Full Changelog: 1.5.2...1.5.3

1.5.2

03 Oct 17:22
Compare
Choose a tag to compare

What's Changed

Update with pip: pip3 install -U pywa

callback: better typing for callback_data and factory

Full Changelog: 1.5.1...1.5.2