pytdbot.handlers.decorators

class pytdbot.handlers.decorators.Decorators[source]

Bases: Updates

Decorators class.

finalizer(filters=None, position=None, inner_object=False, timeout=None)[source]

A decorator to finalize an event object after running all handlers

Parameters:
  • filters (Filter, optional) – An update filter

  • position (int, optional) – The function position in finalizers list. Default is None (append)

  • inner_object (bool, optional) – Wether to pass an inner object of update or not; for example UpdateNewMessage.message. Default is False

  • timeout (float, optional) – Max execution time for the finalizer before it timeout. Default is None

  • self (Client | None)

Raises:

TypeError

Return type:

None

initializer(filters=None, position=None, inner_object=False, timeout=None)[source]

A decorator to initialize an event object before running other handlers

Parameters:
  • filters (Filter, optional) – An update filter

  • position (int, optional) – The function position in initializers list. Default is None (append)

  • inner_object (bool, optional) – Wether to pass an inner object of update or not; for example UpdateNewMessage.message. Default is False

  • timeout (float, optional) – Max execution time for the initializer before it timeout. Default is None

  • self (Client | None)

Raises:

TypeError

Return type:

None

on_message(filters=None, position=None, timeout=None)[source]

A decorator to handle updateNewMessage but with Message object.

Parameters:
  • filters (Filter, optional) – An update filter

  • position (int, optional) – The function position in handlers list. Default is None (append)

  • timeout (float, optional) – Max execution time for the handler before it timeout. Default is None

  • self (Client | None)

Raises:

TypeError

Return type:

None

on_updateScheduledEvent(filters=None, position=None, timeout=None)[source]

A scheduled event has been triggered

Parameters:
  • filters (Filter, optional) – An update filter

  • position (int, optional) – The function position in handlers list. Default is None (append)

  • timeout (float, optional) – Max execution time for the handler before it timeout. Default is None

  • self (Client | None)

Raises:

TypeError

Return type:

None