2.8.0
What's Changed
Update with pip:
pip3 install -U pywa
- [client] indicate text typing status when preparing a message
- [client] adding methods to block/unblock and get blocked users
- [types] adding
ResultandPaginationclasses to help paginate results in some methods - [user] adding
.block()and.unblock()shortcuts - [user] adding
inputfield, available when sending a message to a user - [flows] adding
label_varianttoTextInputandTextArea - [flows] adding generics to prevent type errors when using
ScreenDataandComponentsas refs - [flows] adding
CalendarRangeValuesto use whenCalendarPickermode isrange - [utils] update Version
FLOW_JSONto 7.0 andGRAPH_APIto 22.0
from pywa import WhatsApp, types, filters
wa = WhatsApp(...)
@wa.on_message(filters.contains(*list_of_very_very_bad_words), priority=100)
def check(_: WhatsApp, m: types.Message):
m.indicate_typing() # it can take a while to respond so we indicate typing
if db.check_if_user_already_warned(m.from_user.wa_id):
m.reply("You are blocked for using bad words")
m.from_user.block() # block the user
m.stop_handling()
else:
m.reply("You are warned for using bad words")
db.mark_user_as_warned(m.from_user.wa_id)
m.continue_handling()from pywa.types.flows import *
my_flow = FlowJSON(
screens=[
Screen(
id="WELCOME",
data=[
is_new_user := ScreenData( # boolean screen data
key="is_new_user",
example=True
),
welcome_msg := ScreenData( # string screen data
key="welcome_msg",
example="Welcome to our service!"
),
],
layout=Layout(
children=[
TextBody(
# The type checker will warn you
text=is_new_user.ref,
visible=welcome_msg.ref
),
TextBody(
# Everything is fine here
text=welcome_msg.ref,
visible=is_new_user.ref
)
]
)
)
]
)Full Changelog: 2.7.0...2.8.0