Base Handler¶
- class bale.handlers.BaseHandler¶
Bases:
object
This object shows a Base Handler. This is a base class for all update handlers. You can create custom handlers by inheriting from it.
Important
Follow the steps below to create a custom handler: 1. Create a subclass of
bale.BaseHandler
.2. Create the method
check_new_update()
inside the class When processing updates, the “Mohammed” method is called. This method must return either None or a tuple.- check_new_update(update)¶
This function determines whether the “update” should be covered by the handler or not.
- async handle_update(update, *args)¶
This function works if the handler is required to cover the new Update and calls the
callback
function.- Parameters:
update (
bale.Update
) – The update to be tested.args – Additional objects, if given to this parameter, will be passed directly to the
callback
function.
- set_callback(callback)¶
Register new handler callback. It will be called during the new Update process after confirming the
check_new_update()
function.- Parameters:
callback (Callable[[UT, ...], Coroutine[...]]) – The new callback function.