Created
September 10, 2015 19:59
-
-
Save jonnywilliamson/f73d689ecd7d339d6dbf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Telegram\Bot\Laravel; | |
| use Telegram\Bot\Api; | |
| use Illuminate\Support\ServiceProvider; | |
| /** | |
| * Class TelegramServiceProvider | |
| * | |
| * @package Telegram\Bot\Laravel | |
| * @package Telegram\Bot\Laravel | |
| */ | |
| class TelegramServiceProvider extends ServiceProvider | |
| { | |
| /** | |
| * Indicates if loading of the provider is deferred. | |
| * | |
| * @var bool | |
| */ | |
| protected $defer = true; | |
| /** | |
| * Holds path to Config File. | |
| * | |
| * @var string | |
| */ | |
| protected $config_filepath; | |
| /** | |
| * Bootstrap the application events. | |
| */ | |
| public function boot() | |
| { | |
| $this->publishes([ | |
| $this->config_filepath => config_path('telegram.php'), | |
| ]); | |
| } | |
| /** | |
| * Register the service provider. | |
| */ | |
| public function register() | |
| { | |
| $this->registerTelegram(); | |
| $this->config_filepath = __DIR__.'/config/telegram.php'; | |
| $this->mergeConfigFrom($this->config_filepath, 'telegram'); | |
| } | |
| /** | |
| * Initialize Telegram Bot SDK Library with Default Config. | |
| */ | |
| public function registerTelegram() | |
| { | |
| $this->app->singleton('Telegram\Bot\Api', function ($app) { | |
| $config = $app['config']; | |
| $telegram = new Api( | |
| $config->get('telegram.bot_token', false), | |
| $config->get('telegram.async_requests', false), | |
| $config->get('telegram.http_client_handler', null) | |
| ); | |
| // Register Commands | |
| $telegram->addCommands($config->get('telegram.commands', [])); | |
| return $telegram; | |
| }); | |
| $this->app->alias(Api::class, 'telegram'); | |
| } | |
| /** | |
| * Get the services provided by the provider. | |
| * | |
| * @return array | |
| */ | |
| public function provides() | |
| { | |
| return ['telegram', Api::class]; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment