Madelineproto 停止所有进程(停止事件处理程序)

问题描述 投票:0回答:1

我花了很多时间来发现应该如何停止 Eventhandler 进程,但它不起作用

这是我的代码:

<?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

我试图停止事件处理程序进程(Madelineproto)

php telegram php-telegram-bot
1个回答
0
投票

您应该在处理函数内部的某个地方使用它

/**
 * 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();
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.