diff --git a/src/danog/MadelineProto/Wrappers/Events.php b/src/danog/MadelineProto/Wrappers/Events.php index c0d30cf7..bd69a452 100644 --- a/src/danog/MadelineProto/Wrappers/Events.php +++ b/src/danog/MadelineProto/Wrappers/Events.php @@ -85,6 +85,23 @@ trait Events $this->startUpdateSystem(); } } + /** + * Unset event handler. + * + * @param bool $disableUpdateHandling Whether to also disable internal update handling (will cause errors, otherwise will simply use the NOOP handler) + * + * @return void + */ + public function unsetEventHandler(bool $disableUpdateHandling = false): void + { + $this->event_handler = null; + $this->event_handler_instance = null; + $this->event_handler_methods = []; + $this->setNoop(); + if ($disableUpdateHandling) { + $this->settings['updates']['handle_updates'] = false; + } + } /** * Get event handler. *