Skip to content

Madeline Proto Settings

Setiawan edited this page Nov 20, 2020 · 1 revision

All MadelineProto settings from settings documentation can be defined at telegram.php config file by filling the settings array.

    // ...

    /*
    |--------------------------------------------------------------------------
    | Madeline Proto Settings
    |--------------------------------------------------------------------------
    |
    | An array that contains some other arrays, which are the settings for
    | a specific MadelineProto function.
    |
    | Please see documentations for more details.
    |
    */

    'settings' => [

        'logger' => [

            'logger' => Logger::FILE_LOGGER,

            'logger_param' => env('MP_LOGGER_PATH', storage_path('logs/madeline_proto_' . date('dmY') . '.log')),

        ],

        'app_info' => [

            'api_id' => env('MP_TELEGRAM_API_ID', ''),

            'api_hash' => env('MP_TELEGRAM_API_HASH', ''),

        ],
    ],

The settings config above will be loaded if there's no settings array passed into Hu\MadelineProto\Facades\Factory facade or \MadelineProto\Factories\MadelineProtoFactory's make() or get() method's second argument ($config).

See example below:

// YourController.php

// ...
use Hu\MadelineProto\Factories\MadelineProtoFactory;
use Hu\MadelineProto\Facades\Factory;

// ...

    /**
     * @var MadelineProtoFactory
     */
    private $factory;

    public function __construct(MadelineProtoFactory $factory)
    {
        $this->factory = $factory;
    }

    public function methodName() {

        $customSettings = [
            // your custom settings
        ];

        Factory::make($filename, $customSettings); // using custom settings
        // or
        $this->factory->make($filename); // using telegram.php settings

        // ...
    }

// ...
Clone this wiki locally