Simplify combined
This commit is contained in:
parent
e44490c9dc
commit
648b0a1250
|
@ -48,7 +48,7 @@ composer.json:
|
||||||
"description": "Project description",
|
"description": "Project description",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"danog/madelineproto": "^5.0"
|
"danog/madelineproto": "^5"
|
||||||
},
|
},
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|
|
@ -173,28 +173,10 @@ foreach ([
|
||||||
'user2.madeline' => 'Userbot login (2)'
|
'user2.madeline' => 'Userbot login (2)'
|
||||||
] as $session => $message) {
|
] as $session => $message) {
|
||||||
Logger::log($message, Logger::WARNING);
|
Logger::log($message, Logger::WARNING);
|
||||||
$MadelineProto = new API($session);
|
$MadelineProtos []= (new API($session))->startAndLoopBackground(MyEventHandler::class);
|
||||||
$MadelineProto->async(true);
|
|
||||||
$MadelineProto->loop(function () use ($MadelineProto) {
|
|
||||||
yield $MadelineProto->start();
|
|
||||||
yield $MadelineProto->setEventHandler(MyEventHandler::class);
|
|
||||||
});
|
|
||||||
$MadelineProtos []= $MadelineProto->loopFork();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
Tools::wait(Tools::all($MadelineProtos));
|
||||||
$thrown = false;
|
|
||||||
try {
|
|
||||||
Tools::wait(Tools::all($MadelineProtos));
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
$thrown = true;
|
|
||||||
try {
|
|
||||||
$MadelineProto->report("Surfaced: $e");
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
$MadelineProto->logger((string) $e, \danog\MadelineProto\Logger::FATAL_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while ($thrown);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This will create an event handler class `EventHandler`, create a **combined** MadelineProto session with session files `bot.madeline`, `user.madeline`, `user2.madeline`, and set the event handler class to our newly created event handler.
|
This will create an event handler class `EventHandler`, create a **combined** MadelineProto session with session files `bot.madeline`, `user.madeline`, `user2.madeline`, and set the event handler class to our newly created event handler.
|
||||||
|
|
Loading…
Reference in New Issue