Use this decorator to automatically register a function for handling disconnections.
        This does the same thing as :meth:`add_handler` using the :class:`DisconnectHandler`.

def on_disconnect(self=None) -> callable:
        """Use this decorator to automatically register a function for handling disconnections.
        This does the same thing as :meth:`add_handler` using the :class:`DisconnectHandler`.
        """

        def decorator(func: callable) -> Handler:
            handler = pyrogram.DisconnectHandler(func)

            if self is not None:
                self.add_handler(handler)

            return handler

        return decorator