From 8e3937251584bdb04023c868cb433c0f90a6dcaa Mon Sep 17 00:00:00 2001 From: Setiawan Hu Date: Sun, 16 Aug 2020 23:01:38 +0700 Subject: [PATCH 1/4] Updated telegram.php config file updated: - split the log file to each day to avoid "hang" when the log file size is exceeding 2 MB --- config/telegram.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/telegram.php b/config/telegram.php index 73eb5a1..2d92e1e 100644 --- a/config/telegram.php +++ b/config/telegram.php @@ -49,7 +49,7 @@ return [ 'logger' => Logger::FILE_LOGGER, - 'logger_param' => env('MP_LOGGER_PATH', storage_path('logs/madeline-proto.log')), + 'logger_param' => env('MP_LOGGER_PATH', storage_path('logs/madeline-proto(' . date('d-M-Y') . ').log')), ], From aa75d84f9eab6cc4de7f033998b70169f9bbbbb6 Mon Sep 17 00:00:00 2001 From: Setiawan Hu Date: Sun, 16 Aug 2020 23:09:25 +0700 Subject: [PATCH 2/4] Revert "Updated telegram.php config file" This reverts commit 8e393725 --- config/telegram.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/telegram.php b/config/telegram.php index 2d92e1e..73eb5a1 100644 --- a/config/telegram.php +++ b/config/telegram.php @@ -49,7 +49,7 @@ return [ 'logger' => Logger::FILE_LOGGER, - 'logger_param' => env('MP_LOGGER_PATH', storage_path('logs/madeline-proto(' . date('d-M-Y') . ').log')), + 'logger_param' => env('MP_LOGGER_PATH', storage_path('logs/madeline-proto.log')), ], From d01032f312b86d48d60b6bfcf526673ba8950706 Mon Sep 17 00:00:00 2001 From: Setiawan Hu Date: Sun, 16 Aug 2020 23:18:49 +0700 Subject: [PATCH 3/4] Updated telegram.php config file updated: - split the log file to each day to avoid "hang" when the log file size is exceeding 3 MB --- config/telegram.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/telegram.php b/config/telegram.php index 73eb5a1..2a93d15 100644 --- a/config/telegram.php +++ b/config/telegram.php @@ -49,7 +49,7 @@ return [ 'logger' => Logger::FILE_LOGGER, - 'logger_param' => env('MP_LOGGER_PATH', storage_path('logs/madeline-proto.log')), + 'logger_param' => env('MP_LOGGER_PATH', storage_path('logs/madeline_proto_' . date('dmY') . '.log')), ], From b29f70edfa36a524ca3da09ebe0dce057ecc80c3 Mon Sep 17 00:00:00 2001 From: Setiawan Hu Date: Tue, 18 Aug 2020 17:23:02 +0700 Subject: [PATCH 4/4] Refactoring MadelineProtoFactory changed: - move the create telegram session folder at storage path logic to when the vendor:publish command is executed --- src/Factories/MadelineProtoFactory.php | 4 ---- src/MadelineProtoServiceProvider.php | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Factories/MadelineProtoFactory.php b/src/Factories/MadelineProtoFactory.php index 9577b3c..c80540c 100644 --- a/src/Factories/MadelineProtoFactory.php +++ b/src/Factories/MadelineProtoFactory.php @@ -70,10 +70,6 @@ class MadelineProtoFactory $config = config('telegram.settings'); } - if (!file_exists(storage_path("app/telegram/"))) { - mkdir(storage_path("app/telegram"), 0755); - } - $client = new API(storage_path("app/telegram/$sessionFile"), $config); return new MadelineProto($client); diff --git a/src/MadelineProtoServiceProvider.php b/src/MadelineProtoServiceProvider.php index 69c8ee9..867c4c3 100644 --- a/src/MadelineProtoServiceProvider.php +++ b/src/MadelineProtoServiceProvider.php @@ -52,6 +52,8 @@ class MadelineProtoServiceProvider extends ServiceProvider if ($this->app->runningInConsole()) { $this->registerCommands(); + $this->generateTelegramSessionFolder(); + $this->publishes([ __DIR__ . '/../config/telegram.php' => config_path('telegram.php') ]); @@ -71,6 +73,18 @@ class MadelineProtoServiceProvider extends ServiceProvider ]); } + /** + * Create telegram session folder at storage path. + * + * @return void + */ + public function generateTelegramSessionFolder() + { + if (!file_exists(storage_path("app/telegram/"))) { + mkdir(storage_path("app/telegram"), 0755); + } + } + /** * @inheritDoc */