diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..7779491 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,12 @@ +/.github export-ignore +/tests export-ignore +.codeclimate.yml export-ignore +.editorconfig export-ignore +.gitattributes export-ignore +.gitignore export-ignore +.styleci.yml export-ignore +CHANGELOG.md export-ignore +CODE_OF_CONDUCT.md export-ignore +phpunit.xml.dist export-ignore +psalm.xml export-ignore +README.md export-ignore diff --git a/composer.json b/composer.json index 8b74985..f4a343d 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "require": { "php": "^8.2", "nunomaduro/termwind": "^1.0|^2.0", - "nutgram/nutgram": "^4.17.0" + "nutgram/nutgram": "dev-single-polling-update" }, "require-dev": { "illuminate/testing": "^9.0|^10.0|^11.0", diff --git a/composer.phar b/composer.phar deleted file mode 100644 index cc434ae..0000000 Binary files a/composer.phar and /dev/null differ diff --git a/src/Console/ListenCommand.php b/src/Console/ListenCommand.php new file mode 100644 index 0000000..c4e1d28 --- /dev/null +++ b/src/Console/ListenCommand.php @@ -0,0 +1,25 @@ +info('Listening...'); + while (true) { + app()->forgetInstance(Nutgram::class); + $bot = app(Nutgram::class); + $bot->setRunningMode(SingleUpdate::class); + $bot->run(); + } + } +} diff --git a/src/NutgramServiceProvider.php b/src/NutgramServiceProvider.php index b7bfe34..52650e3 100644 --- a/src/NutgramServiceProvider.php +++ b/src/NutgramServiceProvider.php @@ -72,6 +72,14 @@ public function register() return $bot; }); + $this->app->resolving(Nutgram::class, function (Nutgram $bot, Application $app) { + if (config('nutgram.routes', false)) { + (function () use ($bot) { + require file_exists($this->telegramRoutes) ? $this->telegramRoutes : self::ROUTES_PATH; + })(); + } + }); + $this->app->alias(Nutgram::class, 'nutgram'); $this->app->alias(Nutgram::class, FakeNutgram::class); $this->app->singleton('telegram', fn (Application $app) => $app->get(Nutgram::class)); @@ -91,6 +99,7 @@ public function boot(): void $this->commands([ Console\RunCommand::class, + Console\ListenCommand::class, Console\RegisterCommandsCommand::class, Console\HookInfoCommand::class, Console\HookRemoveCommand::class, @@ -110,10 +119,5 @@ public function boot(): void self::ROUTES_PATH => $this->telegramRoutes, ], 'nutgram'); } - - if (config('nutgram.routes', false)) { - $bot = $this->app->get(Nutgram::class); - require file_exists($this->telegramRoutes) ? $this->telegramRoutes : self::ROUTES_PATH; - } } }