1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-22 13:53:04 +01:00

Try slightly different approach

This commit is contained in:
Daniil Gentili 2023-07-08 22:37:13 +02:00
parent 47f53cf049
commit 8b65f51bb0
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 9 additions and 14 deletions

View File

@ -187,6 +187,10 @@ class MyEventHandler extends EventHandler
}
}
if (MyEventHandler::isPluginMode()) {
return MyEventHandler::class;
}
$settings = new Settings;
$settings->getLogger()->setLevel(Logger::LEVEL_ULTRA_VERBOSE);

View File

@ -49,6 +49,9 @@ abstract class EventHandler extends AbstractAPI
DbPropertiesTrait::initDb as private internalInitDb;
}
private static bool $includingPlugins = false;
final public static function isPluginMode(): bool {
return self::$includingPlugins;
}
/**
* Start MadelineProto and the event handler.
*
@ -56,17 +59,11 @@ abstract class EventHandler extends AbstractAPI
*
* @param string $session Session name
* @param SettingsAbstract $settings Settings
*
* @return class-string|never The current class name will only be returned if we're currently including plugins.
*/
final public static function startAndLoop(string $session, SettingsAbstract $settings): string
final public static function startAndLoop(string $session, SettingsAbstract $settings): void
{
if (self::$includingPlugins) {
return static::class;
}
$API = new API($session, $settings);
$API->startAndLoopInternal(static::class);
return static::class;
}
/**
* Start MadelineProto as a bot and the event handler.
@ -76,18 +73,12 @@ abstract class EventHandler extends AbstractAPI
* @param string $session Session name
* @param string $token Bot token
* @param SettingsAbstract $settings Settings
*
* @return class-string|never The current class name will only be returned if we're currently including plugins.
*/
final public static function startAndLoopBot(string $session, string $token, SettingsAbstract $settings): string
final public static function startAndLoopBot(string $session, string $token, SettingsAbstract $settings): void
{
if (self::$includingPlugins) {
return static::class;
}
$API = new API($session, $settings);
$API->botLogin($token);
$API->startAndLoopInternal(static::class);
return static::class;
}
/** @internal */
final protected function reconnectFull(): bool