Sepehr Mir
Sepehr Mir

Reputation: 11

Madelineproto stop all process (stop Eventhandler)

I spend lots of time to discover how i should to stop Eventhandler process but it didn't work

this is my code:

<?PHP
self::$MadelineProto = new API('session.madeline', $settings);
self::$MadelineProto->startAndLoop(Events::class);
// self::$MadelineProto->stop(); not working 
// self::$MadelineProto->logout(); not working
// self::$MadelineProto->auth->logOut(); not working

I tried to stop eventhandler process (Madelineproto)

Upvotes: 1

Views: 471

Answers (1)

You should use it somewhere inside handler functions

/**
 * Handle incoming updates from users, chats and channels.
 */
#[Handler]
public function handleMessage(Incoming&Message $message): void
{
    // Code that uses $message...
    // See the following pages for more examples and documentation:
    // - https://github.com/danog/MadelineProto/blob/v8/examples/bot.php
    // - https://docs.madelineproto.xyz/docs/UPDATES.html
    // - https://docs.madelineproto.xyz/docs/FILTERS.html
    // - https://docs.madelineproto.xyz/

    if( in_array($message->chatId, self::listChannels) ) {
        $this->messages->forwardMessages(from_peer:$message->chatId, id: [$message->id], to_peer: self::ADMIN);
        $this->stop();
    }
}

Upvotes: 0

Related Questions