telegram-bot-sdk icon indicating copy to clipboard operation
telegram-bot-sdk copied to clipboard

Ability to use named route instead of webhook url

Open ddzobov opened this issue 3 years ago • 3 comments

Hello!

Currently configuration requires to put full webhook url into webhook_url key like this:

'bots'                         => [
        'MyBot' => [
            'username'            => env('TELEGRAM_USERNAME', ''),
            'token'               => env('TELEGRAM_TOKEN', ''),
            'certificate_path'    => env('TELEGRAM_CERTIFICATE_PATH', ''),
            'webhook_url'         => env('TELEGRAM_WEBHOOK_URL', ''),
            'commands'            => [

            ],
        ],
    ],

Maybe better way to set it this way? When webhook_route_name is set, webhook_url will be ignored.

Or we can validate value of webhook_url - if it is not valid URL try to pass it to secure_route() method.

'bots'                         => [
        'MyBot' => [
            'username'            => env('TELEGRAM_USERNAME', ''),
            'token'               => env('TELEGRAM_TOKEN', ''),
            'certificate_path'    => env('TELEGRAM_CERTIFICATE_PATH', ''),
            'webhook_url'         => env('TELEGRAM_WEBHOOK_URL', ''),
            'webhook_route_name'         => 'telegram.webhook',
            'commands'            => [

            ],
        ],
    ],

ddzobov avatar Jan 26 '21 13:01 ddzobov

Hey!

You can just use route('telegram.webhook') and set the value for webhook_url config.

We don't need another option.

irazasyed avatar Jan 26 '21 18:01 irazasyed

I’m not able to use route inside config files because configs are loaded before container

ddzobov avatar Jan 26 '21 19:01 ddzobov

'bots'                         => [
        'MyBot' => [
            'username'            => env('TELEGRAM_USERNAME', ''),
            'token'               => env('TELEGRAM_TOKEN', ''),
            'certificate_path'    => env('TELEGRAM_CERTIFICATE_PATH', ''),
            'webhook_url'         => route('telegram.webhook'), // this line causes error
            'commands'            => [

            ],
        ],
    ],

ddzobov avatar Jan 27 '21 10:01 ddzobov