pytdbot.handlers

class pytdbot.handlers.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

class pytdbot.handlers.Handler(func, update_type, filter=None, position=None, inner_object=False, timeout=None, is_from_plugin=False)[source]

Bases: object

A handler class.

Parameters:
  • func (Callable)

  • update_type (str)

  • filter (Filter)

  • position (int)

  • inner_object (bool)

  • timeout (float)

  • is_from_plugin (bool)

__init__(func, update_type, filter=None, position=None, inner_object=False, timeout=None, is_from_plugin=False)[source]
Parameters:
  • func (Callable)

  • update_type (str)

  • filter (Filter | None)

  • position (int | None)

  • inner_object (bool)

  • timeout (float | None)

  • is_from_plugin (bool)

Return type:

None

Modules