diff --git a/conf/site/vendor/composer/autoload_classmap.php b/conf/site/vendor/composer/autoload_classmap.php index eb4716c4..4ae3261d 100644 --- a/conf/site/vendor/composer/autoload_classmap.php +++ b/conf/site/vendor/composer/autoload_classmap.php @@ -37,7 +37,8 @@ return array( 'App\\Http\\Middleware\\VerifyCsrfToken' => $baseDir . '/app/Http/Middleware/VerifyCsrfToken.php', 'App\\Jobs\\SpeedtestJob' => $baseDir . '/app/Jobs/SpeedtestJob.php', 'App\\Listeners\\SpeedtestCompleteListener' => $baseDir . '/app/Listeners/SpeedtestCompleteListener.php', - 'App\\Notifications\\SpeedtestComplete' => $baseDir . '/app/Notifications/SpeedtestComplete.php', + 'App\\Notifications\\SpeedtestCompleteSlack' => $baseDir . '/app/Notifications/SpeedtestCompleteSlack.php', + 'App\\Notifications\\SpeedtestCompleteTelegram' => $baseDir . '/app/Notifications/SpeedtestCompleteTelegram.php', 'App\\Providers\\AppServiceProvider' => $baseDir . '/app/Providers/AppServiceProvider.php', 'App\\Providers\\AuthServiceProvider' => $baseDir . '/app/Providers/AuthServiceProvider.php', 'App\\Providers\\BroadcastServiceProvider' => $baseDir . '/app/Providers/BroadcastServiceProvider.php', @@ -2702,6 +2703,14 @@ return array( 'Namshi\\JOSE\\Signer\\SignerInterface' => $vendorDir . '/namshi/jose/src/Namshi/JOSE/Signer/SignerInterface.php', 'Namshi\\JOSE\\SimpleJWS' => $vendorDir . '/namshi/jose/src/Namshi/JOSE/SimpleJWS.php', 'Normalizer' => $vendorDir . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php', + 'NotificationChannels\\Telegram\\Exceptions\\CouldNotSendNotification' => $vendorDir . '/laravel-notification-channels/telegram/src/Exceptions/CouldNotSendNotification.php', + 'NotificationChannels\\Telegram\\Telegram' => $vendorDir . '/laravel-notification-channels/telegram/src/Telegram.php', + 'NotificationChannels\\Telegram\\TelegramChannel' => $vendorDir . '/laravel-notification-channels/telegram/src/TelegramChannel.php', + 'NotificationChannels\\Telegram\\TelegramFile' => $vendorDir . '/laravel-notification-channels/telegram/src/TelegramFile.php', + 'NotificationChannels\\Telegram\\TelegramLocation' => $vendorDir . '/laravel-notification-channels/telegram/src/TelegramLocation.php', + 'NotificationChannels\\Telegram\\TelegramMessage' => $vendorDir . '/laravel-notification-channels/telegram/src/TelegramMessage.php', + 'NotificationChannels\\Telegram\\TelegramServiceProvider' => $vendorDir . '/laravel-notification-channels/telegram/src/TelegramServiceProvider.php', + 'NotificationChannels\\Telegram\\Traits\\HasSharedLogic' => $vendorDir . '/laravel-notification-channels/telegram/src/Traits/HasSharedLogic.php', 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider' => $vendorDir . '/nunomaduro/collision/src/Adapters/Laravel/CollisionServiceProvider.php', 'NunoMaduro\\Collision\\Adapters\\Laravel\\Commands\\TestCommand' => $vendorDir . '/nunomaduro/collision/src/Adapters/Laravel/Commands/TestCommand.php', 'NunoMaduro\\Collision\\Adapters\\Laravel\\ExceptionHandler' => $vendorDir . '/nunomaduro/collision/src/Adapters/Laravel/ExceptionHandler.php', diff --git a/conf/site/vendor/composer/autoload_files.php b/conf/site/vendor/composer/autoload_files.php index 5ca13bee..473479d0 100644 --- a/conf/site/vendor/composer/autoload_files.php +++ b/conf/site/vendor/composer/autoload_files.php @@ -16,10 +16,10 @@ return array( '667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php', 'def43f6c87e4f8dfd0c9e1b1bab14fe8' => $vendorDir . '/symfony/polyfill-iconv/bootstrap.php', '2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php', - '801c31d8ed748cfa537fa45402288c95' => $vendorDir . '/psy/psysh/src/functions.php', '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php', 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', + '801c31d8ed748cfa537fa45402288c95' => $vendorDir . '/psy/psysh/src/functions.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', '538ca81a9a966a6716601ecf48f4eaef' => $vendorDir . '/opis/closure/functions.php', 'e39a8b23c42d4e1452234d762b03835a' => $vendorDir . '/ramsey/uuid/src/functions.php', diff --git a/conf/site/vendor/composer/autoload_psr4.php b/conf/site/vendor/composer/autoload_psr4.php index 5dbb05ec..7834e203 100644 --- a/conf/site/vendor/composer/autoload_psr4.php +++ b/conf/site/vendor/composer/autoload_psr4.php @@ -54,6 +54,7 @@ return array( 'PhpOption\\' => array($vendorDir . '/phpoption/phpoption/src/PhpOption'), 'Opis\\Closure\\' => array($vendorDir . '/opis/closure/src'), 'NunoMaduro\\Collision\\' => array($vendorDir . '/nunomaduro/collision/src'), + 'NotificationChannels\\Telegram\\' => array($vendorDir . '/laravel-notification-channels/telegram/src'), 'Namshi\\JOSE\\' => array($vendorDir . '/namshi/jose/src/Namshi/JOSE'), 'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'), 'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'), diff --git a/conf/site/vendor/composer/autoload_static.php b/conf/site/vendor/composer/autoload_static.php index 82937393..e810c01e 100644 --- a/conf/site/vendor/composer/autoload_static.php +++ b/conf/site/vendor/composer/autoload_static.php @@ -17,10 +17,10 @@ class ComposerStaticInita54da675f7e63b2b06cffe7d297f5df8 '667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php', 'def43f6c87e4f8dfd0c9e1b1bab14fe8' => __DIR__ . '/..' . '/symfony/polyfill-iconv/bootstrap.php', '2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php', - '801c31d8ed748cfa537fa45402288c95' => __DIR__ . '/..' . '/psy/psysh/src/functions.php', '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php', + '801c31d8ed748cfa537fa45402288c95' => __DIR__ . '/..' . '/psy/psysh/src/functions.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', '538ca81a9a966a6716601ecf48f4eaef' => __DIR__ . '/..' . '/opis/closure/functions.php', 'e39a8b23c42d4e1452234d762b03835a' => __DIR__ . '/..' . '/ramsey/uuid/src/functions.php', @@ -114,6 +114,7 @@ class ComposerStaticInita54da675f7e63b2b06cffe7d297f5df8 'N' => array ( 'NunoMaduro\\Collision\\' => 21, + 'NotificationChannels\\Telegram\\' => 30, 'Namshi\\JOSE\\' => 12, ), 'M' => @@ -375,6 +376,10 @@ class ComposerStaticInita54da675f7e63b2b06cffe7d297f5df8 array ( 0 => __DIR__ . '/..' . '/nunomaduro/collision/src', ), + 'NotificationChannels\\Telegram\\' => + array ( + 0 => __DIR__ . '/..' . '/laravel-notification-channels/telegram/src', + ), 'Namshi\\JOSE\\' => array ( 0 => __DIR__ . '/..' . '/namshi/jose/src/Namshi/JOSE', @@ -562,7 +567,8 @@ class ComposerStaticInita54da675f7e63b2b06cffe7d297f5df8 'App\\Http\\Middleware\\VerifyCsrfToken' => __DIR__ . '/../..' . '/app/Http/Middleware/VerifyCsrfToken.php', 'App\\Jobs\\SpeedtestJob' => __DIR__ . '/../..' . '/app/Jobs/SpeedtestJob.php', 'App\\Listeners\\SpeedtestCompleteListener' => __DIR__ . '/../..' . '/app/Listeners/SpeedtestCompleteListener.php', - 'App\\Notifications\\SpeedtestComplete' => __DIR__ . '/../..' . '/app/Notifications/SpeedtestComplete.php', + 'App\\Notifications\\SpeedtestCompleteSlack' => __DIR__ . '/../..' . '/app/Notifications/SpeedtestCompleteSlack.php', + 'App\\Notifications\\SpeedtestCompleteTelegram' => __DIR__ . '/../..' . '/app/Notifications/SpeedtestCompleteTelegram.php', 'App\\Providers\\AppServiceProvider' => __DIR__ . '/../..' . '/app/Providers/AppServiceProvider.php', 'App\\Providers\\AuthServiceProvider' => __DIR__ . '/../..' . '/app/Providers/AuthServiceProvider.php', 'App\\Providers\\BroadcastServiceProvider' => __DIR__ . '/../..' . '/app/Providers/BroadcastServiceProvider.php', @@ -3227,6 +3233,14 @@ class ComposerStaticInita54da675f7e63b2b06cffe7d297f5df8 'Namshi\\JOSE\\Signer\\SignerInterface' => __DIR__ . '/..' . '/namshi/jose/src/Namshi/JOSE/Signer/SignerInterface.php', 'Namshi\\JOSE\\SimpleJWS' => __DIR__ . '/..' . '/namshi/jose/src/Namshi/JOSE/SimpleJWS.php', 'Normalizer' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php', + 'NotificationChannels\\Telegram\\Exceptions\\CouldNotSendNotification' => __DIR__ . '/..' . '/laravel-notification-channels/telegram/src/Exceptions/CouldNotSendNotification.php', + 'NotificationChannels\\Telegram\\Telegram' => __DIR__ . '/..' . '/laravel-notification-channels/telegram/src/Telegram.php', + 'NotificationChannels\\Telegram\\TelegramChannel' => __DIR__ . '/..' . '/laravel-notification-channels/telegram/src/TelegramChannel.php', + 'NotificationChannels\\Telegram\\TelegramFile' => __DIR__ . '/..' . '/laravel-notification-channels/telegram/src/TelegramFile.php', + 'NotificationChannels\\Telegram\\TelegramLocation' => __DIR__ . '/..' . '/laravel-notification-channels/telegram/src/TelegramLocation.php', + 'NotificationChannels\\Telegram\\TelegramMessage' => __DIR__ . '/..' . '/laravel-notification-channels/telegram/src/TelegramMessage.php', + 'NotificationChannels\\Telegram\\TelegramServiceProvider' => __DIR__ . '/..' . '/laravel-notification-channels/telegram/src/TelegramServiceProvider.php', + 'NotificationChannels\\Telegram\\Traits\\HasSharedLogic' => __DIR__ . '/..' . '/laravel-notification-channels/telegram/src/Traits/HasSharedLogic.php', 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider' => __DIR__ . '/..' . '/nunomaduro/collision/src/Adapters/Laravel/CollisionServiceProvider.php', 'NunoMaduro\\Collision\\Adapters\\Laravel\\Commands\\TestCommand' => __DIR__ . '/..' . '/nunomaduro/collision/src/Adapters/Laravel/Commands/TestCommand.php', 'NunoMaduro\\Collision\\Adapters\\Laravel\\ExceptionHandler' => __DIR__ . '/..' . '/nunomaduro/collision/src/Adapters/Laravel/ExceptionHandler.php', diff --git a/conf/site/vendor/composer/installed.json b/conf/site/vendor/composer/installed.json index a0a73032..37261669 100644 --- a/conf/site/vendor/composer/installed.json +++ b/conf/site/vendor/composer/installed.json @@ -1402,6 +1402,69 @@ "test" ] }, + { + "name": "laravel-notification-channels/telegram", + "version": "0.4.0", + "version_normalized": "0.4.0.0", + "source": { + "type": "git", + "url": "https://github.com/laravel-notification-channels/telegram.git", + "reference": "9e4bb2fbf1a7a06e8849fa2d50bf57fa7c4483e3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel-notification-channels/telegram/zipball/9e4bb2fbf1a7a06e8849fa2d50bf57fa7c4483e3", + "reference": "9e4bb2fbf1a7a06e8849fa2d50bf57fa7c4483e3", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/guzzle": "^6.2", + "illuminate/notifications": "^5.5 || ^6.0 || ^7.0", + "illuminate/support": "^5.5 || ^6.0 || ^7.0", + "php": ">=7.1" + }, + "require-dev": { + "mockery/mockery": "^1.3", + "phpunit/phpunit": "^7.0 || ^8.0" + }, + "time": "2020-06-02T06:05:27+00:00", + "type": "library", + "extra": { + "laravel": { + "providers": [ + "NotificationChannels\\Telegram\\TelegramServiceProvider" + ] + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "NotificationChannels\\Telegram\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Irfaq Syed", + "email": "syed@lukonet.com", + "homepage": "https://lukonet.com", + "role": "Developer" + } + ], + "description": "Telegram Notifications Channel for Laravel", + "homepage": "https://github.com/laravel-notification-channels/telegram", + "keywords": [ + "laravel", + "notification", + "telegram", + "telegram notification", + "telegram notifications channel" + ] + }, { "name": "laravel/framework", "version": "v7.16.1", diff --git a/conf/site/vendor/laravel-notification-channels/telegram/.editorconfig b/conf/site/vendor/laravel-notification-channels/telegram/.editorconfig new file mode 100644 index 00000000..cd8eb86e --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/.editorconfig @@ -0,0 +1,15 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/conf/site/vendor/laravel-notification-channels/telegram/.styleci.yml b/conf/site/vendor/laravel-notification-channels/telegram/.styleci.yml new file mode 100644 index 00000000..0285f179 --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/.styleci.yml @@ -0,0 +1 @@ +preset: laravel diff --git a/conf/site/vendor/laravel-notification-channels/telegram/CHANGELOG.md b/conf/site/vendor/laravel-notification-channels/telegram/CHANGELOG.md new file mode 100755 index 00000000..fc3cd8cc --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/CHANGELOG.md @@ -0,0 +1,61 @@ +# Changelog + +All notable changes to `telegram` will be documented in this file + +## 0.4.0 - 2020-06-02 + +- Add support to set custom api `base_uri` for web bridge. +- Revise README with instructions for Proxy or Bridge support. +- Revise on-demand notification instructions - Fixes [#72](https://github.com/laravel-notification-channels/telegram/issues/72). +- Fix typo in test. +- Remove redundant test. +- Remove exception when chat id isn't provided - PR [#75](https://github.com/laravel-notification-channels/telegram/pull/75). + +## 0.3.0 - 2020-03-26 + +- Add ability to set param in `disableNotification` method. + +## 0.2.0 - 2020-02-19 + +- Laravel 7 Support. +- Support response handling from Telegram. + +## 0.1.1 - 2019-11-07 + +- Support PHP 7.1 and up. + +## 0.1.0 - 2019-10-11 + +- New Helper Methods to work with file attachments. +- Code cleanup. +- Documentation updated with more examples and previews. +- Micro optimization and improvements. +- Typehint and return type declaration. +- Fixed tests. + +## 0.0.6 - 2019-09-28 + +- Laravel 6 Support. +- Add Photo, Document, Audio, Location and other file notification type support. +- Token getter and setter. + +## 0.0.5 - 2018-09-08 + +- Laravel 5.7 Support. +- Add ability to change button columns. + +## 0.0.4 - 2018-02-08 + +- Laravel 5.6 Support. + +## 0.0.3 - 2017-09-01 + +- Laravel 5.5 Support with Auto-Discovery. + +## 0.0.2 - 2017-03-24 + +- Laravel 5.4 Support. + +## 0.0.1 - 2016-08-14 + +- Initial Release. diff --git a/conf/site/vendor/laravel-notification-channels/telegram/CONTRIBUTING.md b/conf/site/vendor/laravel-notification-channels/telegram/CONTRIBUTING.md new file mode 100755 index 00000000..4da74e3f --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/CONTRIBUTING.md @@ -0,0 +1,55 @@ +# Contributing + +Contributions are **welcome** and will be fully **credited**. + +Please read and understand the contribution guide before creating an issue or pull request. + +## Etiquette + +This project is open source, and as such, the maintainers give their free time to build and maintain the source code +held within. They make the code freely available in the hope that it will be of use to other developers. It would be +extremely unfair for them to suffer abuse or anger for their hard work. + +Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the +world that developers are civilized and selfless people. + +It's the duty of the maintainer to ensure that all submissions to the project are of sufficient +quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. + +## Viability + +When requesting or submitting new features, first consider whether it might be useful to others. Open +source projects are used by many developers, who may have entirely different needs to your own. Think about +whether or not your feature is likely to be used by other users of the project. + +## Procedure + +Before filing an issue: + +- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. +- Check to make sure your feature suggestion isn't already present within the project. +- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. +- Check the pull requests tab to ensure that the feature isn't already in progress. + +Before submitting a pull request: + +- Check the codebase to ensure that your feature doesn't already exist. +- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. + +## Requirements + +If the project maintainer has any additional requirements, you will find them listed here. + +- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). + +- **Add tests!** - Your patch won't be accepted if it doesn't have tests. + +- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. + +- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. + +- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. + +- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. + +**Happy coding**! diff --git a/conf/site/vendor/laravel-notification-channels/telegram/LICENSE.md b/conf/site/vendor/laravel-notification-channels/telegram/LICENSE.md new file mode 100644 index 00000000..f72f1808 --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/LICENSE.md @@ -0,0 +1,21 @@ +# The MIT License (MIT) + +Copyright (c) Irfaq Syed + +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in +> all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +> THE SOFTWARE. diff --git a/conf/site/vendor/laravel-notification-channels/telegram/README.md b/conf/site/vendor/laravel-notification-channels/telegram/README.md new file mode 100644 index 00000000..83b6f030 --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/README.md @@ -0,0 +1,302 @@ +# Telegram Notifications Channel for Laravel + +[![Join PHP Chat][ico-phpchat]][link-phpchat] +[![Chat on Telegram][ico-telegram]][link-telegram] +[![Latest Version on Packagist][ico-version]][link-packagist] +[![Software License][ico-license]](LICENSE.md) +[![SensioLabsInsight][ico-sensiolabs]][link-sensiolabs] +[![Quality Score][ico-code-quality]][link-code-quality] +[![Total Downloads][ico-downloads]][link-packagist] + +This package makes it easy to send Telegram notification using [Telegram Bot API](https://core.telegram.org/bots) with Laravel. + +## Contents + +- [Installation](#installation) + - [Setting up your Telegram bot](#setting-up-your-telegram-bot) +- [Usage](#usage) + - [Text Notification](#text-notification) + - [Attach a Photo](#attach-a-photo) + - [Attach a Document](#attach-a-document) + - [Attach a Location](#attach-a-location) + - [Attach a Video](#attach-a-video) + - [Attach a GIF File](#attach-a-gif-file) + - [Routing a Message](#routing-a-message) + - [Handling Response](#handling-response) + - [On-Demand Notifications](#on-demand-notifications) + - [Available Message methods](#available-message-methods) + - [Available Location methods](#available-location-methods) + - [Available File methods](#available-file-methods) +- [Alternatives](#alternatives) +- [Changelog](#changelog) +- [Testing](#testing) +- [Security](#security) +- [Contributing](#contributing) +- [Credits](#credits) +- [License](#license) + +## Installation + +You can install the package via composer: + +```bash +composer require laravel-notification-channels/telegram +``` + +## Setting up your Telegram Bot + +Talk to [@BotFather](https://core.telegram.org/bots#6-botfather) and generate a Bot API Token. + +Then, configure your Telegram Bot API Token: + +```php +// config/services.php +'telegram-bot-api' => [ + 'token' => env('TELEGRAM_BOT_TOKEN', 'YOUR BOT TOKEN HERE') +], +``` + +#### (Optional) Proxy or Bridge Support + +You may not be able to send notifications if Telegram Bot API is not accessible in your country, +you can either set a proxy by following the instructions [here](http://docs.guzzlephp.org/en/stable/quickstart.html#environment-variables) or +use a web bridge by setting the `base_uri` config above with the bridge uri. + +## Usage + +You can now use the channel in your `via()` method inside the Notification class. + +### Text Notification + +```php +use NotificationChannels\Telegram\TelegramChannel; +use NotificationChannels\Telegram\TelegramMessage; +use Illuminate\Notifications\Notification; + +class InvoicePaid extends Notification +{ + public function via($notifiable) + { + return [TelegramChannel::class]; + } + + public function toTelegram($notifiable) + { + $url = url('/invoice/' . $this->invoice->id); + + return TelegramMessage::create() + // Optional recipient user id. + ->to($notifiable->telegram_user_id) + // Markdown supported. + ->content("Hello there!\nYour invoice has been *PAID*") + // (Optional) Inline Buttons + ->button('View Invoice', $url) + ->button('Download Invoice', $url); + } +} +``` + +Here's a screenshot preview of the above notification on Telegram Messenger: + +![Laravel Telegram Notification Example](https://user-images.githubusercontent.com/1915268/66616627-39be6180-ebef-11e9-92cc-f2da81da047a.jpg) + +### Attach a Photo + +```php +public function toTelegram($notifiable) +{ + return TelegramFile::create() + ->to($notifiable->telegram_user_id) // Optional + ->content('Awesome *bold* text and [inline URL](http://www.example.com/)') + ->file('/storage/archive/6029014.jpg', 'photo'); // local photo + + // OR using a helper method with or without a remote file. + // ->photo('https://file-examples.com/wp-content/uploads/2017/10/file_example_JPG_1MB.jpg'); +} +``` + +Preview: + +![Laravel Telegram Photo Notification Example](https://user-images.githubusercontent.com/1915268/66616792-daad1c80-ebef-11e9-9bdf-c0bc484cf037.jpg) + +### Attach a Document + +```php +public function toTelegram($notifiable) +{ + return TelegramFile::create() + ->to($notifiable->telegram_user_id) // Optional + ->content('Did you know we can set a custom filename too?') + ->document('https://file-examples.com/wp-content/uploads/2017/10/file-sample_150kB.pdf', 'sample.pdf'); +} +``` + +Preview: + +![Laravel Telegram Document Notification Example](https://user-images.githubusercontent.com/1915268/66616850-10520580-ebf0-11e9-9122-4f4d263f3b53.jpg) + +### Attach a Location + +```php +public function toTelegram($notifiable) +{ + return TelegramLocation::create() + ->latitude('40.6892494') + ->longitude('-74.0466891'); +} +``` + +Preview: + +![Laravel Telegram Location Notification Example](https://user-images.githubusercontent.com/1915268/66616918-54450a80-ebf0-11e9-86ea-d5264fe05ba9.jpg) + +### Attach a Video + +```php +public function toTelegram($notifiable) +{ + return TelegramFile::create() + ->content('Sample *video* notification!') + ->video('https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_480_1_5MG.mp4'); +} +``` + +Preview: + +![Laravel Telegram Video Notification Example](https://user-images.githubusercontent.com/1915268/66617038-ed742100-ebf0-11e9-865a-bf0245d2cbbb.jpg) + +### Attach a GIF File + +```php +public function toTelegram($notifiable) +{ + return TelegramFile::create() + ->content('Woot! We can send animated gif notifications too!') + ->animation('https://sample-videos.com/gif/2.gif'); + + // Or local file + // ->animation('/path/to/some/animated.gif'); +} +``` + +Preview: + +![Laravel Telegram Gif Notification Example](https://user-images.githubusercontent.com/1915268/66617071-109ed080-ebf1-11e9-989b-b237f2b9502d.jpg) + +### Routing a Message + +You can either send the notification by providing with the chat ID of the recipient to the `to($chatId)` method like shown in the previous examples or add a `routeNotificationForTelegram()` method in your notifiable model: + +```php +/** + * Route notifications for the Telegram channel. + * + * @return int + */ +public function routeNotificationForTelegram() +{ + return $this->telegram_user_id; +} +``` + +### Handling Response + +You can make use of the [notification events](https://laravel.com/docs/5.8/notifications#notification-events) to handle the response from Telegram. On success, your event listener will recieve a [Message](https://core.telegram.org/bots/api#message) object with various fields as appropriate to the notification type. + +For a complete list of response fields, please refer the Telegram Bot API's [Message object](https://core.telegram.org/bots/api#message) docs. + +### On-Demand Notifications + +> Sometimes you may need to send a notification to someone who is not stored as a "user" of your application. Using the `Notification::route` method, you may specify ad-hoc notification routing information before sending the notification. For more details, you can check out the [on-demand notifications](https://laravel.com/docs/5.8/notifications#on-demand-notifications) docs. + +```php +use NotificationChannels\Telegram\TelegramChannel; + +Notification::route('telegram', 'TELEGRAM_CHAT_ID') + ->notify(new InvoicePaid($invoice)); +``` + +### Available Message methods + +- `to($chatId)`: (integer) Recipient's chat id. +- `content('')`: (string) Notification message, supports markdown. For more information on supported markdown styles, check out these [docs](https://telegram-bot-sdk.readme.io/reference#section-formatting-options). +- `button($text, $url)`: (string) Adds an inline "Call to Action" button. You can add as many as you want and they'll be placed 2 in a row. +- `disableNotification($disableNotification = true)`: (bool) Send the message silently. Users will receive a notification with no sound. +- `options([])`: (array) Allows you to add additional or override `sendMessage` payload (A Telegram Bot API method used to send message internally). For more information on supported parameters, check out these [docs](https://telegram-bot-sdk.readme.io/docs/sendmessage). + +### Available Location methods + +- `to($chatId)`: (integer) Recipient's chat id. +- `latitude($latitude)`: (float|string) Latitude of the location. +- `longitude($longitude)`: (float|string) Longitude of the location. +- `button($text, $url)`: (string) Adds an inline "Call to Action" button. You can add as many as you want and they'll be placed 2 in a row. +- `disableNotification($disableNotification = true)`: (bool) Send the message silently. Users will receive a notification with no sound. +- `options([])`: (array) Allows you to add additional or override the payload. + +### Available File methods + +- `to($chatId)`: (integer) Recipient's chat id. +- `content('')`: (string) File caption, supports markdown. For more information on supported markdown styles, check out these [docs](https://telegram-bot-sdk.readme.io/reference#section-formatting-options). +- `file($file, $type, $filename = null)`: Local file path or remote URL, `$type` of the file (Ex:`photo`, `audio`, `document`, `video`, `animation`, `voice`, `video_note_`) and optionally filename with extension. Ex: `sample.pdf`. You can use helper methods instead of using this to make it easier to work with file attachment. +- `photo($file)`: Helper method to attach a photo. +- `audio($file)`: Helper method to attach an audio file (MP3 file). +- `document($file, $filename = null)`: Helper method to attach a document or any file as document. +- `video($file)`: Helper method to attach a video file. +- `animation($file)`: Helper method to attach an animated gif file. +- `voice($file)`: Helper method to attach a voice note (`.ogg` file with OPUS encoded). +- `videoNote($file)`: Helper method to attach a video note file (Upto 1 min long, rounded square video). +- `button($text, $url)`: (string) Adds an inline "Call to Action" button. You can add as many as you want and they'll be placed 2 in a row. +- `disableNotification($disableNotification = true)`: (bool) Send the message silently. Users will receive a notification with no sound. +- `options([])`: (array) Allows you to add additional or override the payload. + +## Alternatives + +For advance usage, please consider using [telegram-bot-sdk](https://github.com/irazasyed/telegram-bot-sdk) instead. + +## Changelog + +Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. + +## Testing + +```bash +$ composer test +``` + +## Security + +If you discover any security related issues, please email syed@lukonet.com instead of using the issue tracker. + +## Contributing + +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. + +## Credits + +- [Irfaq Syed][link-author] +- [All Contributors][link-contributors] + +## License + +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. + +[ico-phpchat]: https://img.shields.io/badge/Slack-PHP%20Chat-5c6aaa.svg?style=flat-square&logo=slack&labelColor=4A154B +[ico-telegram]: https://img.shields.io/badge/@PHPChatCo-2CA5E0.svg?style=flat-square&logo=telegram&label=Telegram +[ico-version]: https://img.shields.io/packagist/v/laravel-notification-channels/telegram.svg?style=flat-square +[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square +[ico-travis]: https://img.shields.io/travis/laravel-notification-channels/telegram/master.svg?style=flat-square +[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/laravel-notification-channels/telegram.svg?style=flat-square +[ico-code-quality]: https://img.shields.io/scrutinizer/g/laravel-notification-channels/telegram.svg?style=flat-square +[ico-downloads]: https://img.shields.io/packagist/dt/laravel-notification-channels/telegram.svg?style=flat-square +[ico-sensiolabs]: https://img.shields.io/sensiolabs/i/d28e31ec-55ce-4306-88a3-84d5d14ad3db.svg?style=flat-square + +[link-phpchat]: https://phpchat.co/?ref=laravel-channel-telegram +[link-telegram]: https://t.me/PHPChatCo +[link-repo]: https://github.com/laravel-notification-channels/telegram +[link-packagist]: https://packagist.org/packages/laravel-notification-channels/telegram +[link-travis]: https://travis-ci.org/laravel-notification-channels/telegram +[link-scrutinizer]: https://scrutinizer-ci.com/g/laravel-notification-channels/telegram/code-structure +[link-sensiolabs]: https://insight.sensiolabs.com/projects/d28e31ec-55ce-4306-88a3-84d5d14ad3db +[link-code-quality]: https://scrutinizer-ci.com/g/laravel-notification-channels/telegram +[link-author]: https://github.com/irazasyed +[link-contributors]: ../../contributors diff --git a/conf/site/vendor/laravel-notification-channels/telegram/composer.json b/conf/site/vendor/laravel-notification-channels/telegram/composer.json new file mode 100644 index 00000000..6ec22be8 --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/composer.json @@ -0,0 +1,56 @@ +{ + "name": "laravel-notification-channels/telegram", + "description": "Telegram Notifications Channel for Laravel", + "keywords": [ + "telegram notification", + "laravel", + "telegram", + "notification", + "telegram notifications channel" + ], + "homepage": "https://github.com/laravel-notification-channels/telegram", + "license": "MIT", + "authors": [ + { + "name": "Irfaq Syed", + "email": "syed@lukonet.com", + "homepage": "https://lukonet.com", + "role": "Developer" + } + ], + "require": { + "php": ">=7.1", + "ext-json": "*", + "guzzlehttp/guzzle": "^6.2", + "illuminate/notifications": "^5.5 || ^6.0 || ^7.0", + "illuminate/support": "^5.5 || ^6.0 || ^7.0" + }, + "require-dev": { + "mockery/mockery": "^1.3", + "phpunit/phpunit": "^7.0 || ^8.0" + }, + "autoload": { + "psr-4": { + "NotificationChannels\\Telegram\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "NotificationChannels\\Telegram\\Test\\": "tests" + } + }, + "scripts": { + "test": "phpunit", + "test:coverage": "phpunit --coverage-text --coverage-clover=coverage.clover" + }, + "config": { + "sort-packages": true + }, + "extra": { + "laravel": { + "providers": [ + "NotificationChannels\\Telegram\\TelegramServiceProvider" + ] + } + } +} diff --git a/conf/site/vendor/laravel-notification-channels/telegram/src/Exceptions/CouldNotSendNotification.php b/conf/site/vendor/laravel-notification-channels/telegram/src/Exceptions/CouldNotSendNotification.php new file mode 100644 index 00000000..b6aab89d --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/src/Exceptions/CouldNotSendNotification.php @@ -0,0 +1,57 @@ +hasResponse()) { + return new static('Telegram responded with an error but no response body found'); + } + + $statusCode = $exception->getResponse()->getStatusCode(); + + $result = json_decode($exception->getResponse()->getBody(), false); + $description = $result->description ?? 'no description given'; + + return new static("Telegram responded with an error `{$statusCode} - {$description}`"); + } + + /** + * Thrown when there's no bot token provided. + * + * @param string $message + * + * @return static + */ + public static function telegramBotTokenNotProvided($message): self + { + return new static($message); + } + + /** + * Thrown when we're unable to communicate with Telegram. + * + * @param $message + * + * @return static + */ + public static function couldNotCommunicateWithTelegram($message): self + { + return new static("The communication with Telegram failed. `{$message}`"); + } +} diff --git a/conf/site/vendor/laravel-notification-channels/telegram/src/Telegram.php b/conf/site/vendor/laravel-notification-channels/telegram/src/Telegram.php new file mode 100644 index 00000000..f581d51f --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/src/Telegram.php @@ -0,0 +1,183 @@ +token = $token; + $this->http = $httpClient ?? new HttpClient(); + $this->setApiBaseUri($apiBaseUri ?? 'https://api.telegram.org'); + } + + /** + * Token getter. + * + * @return string + */ + public function getToken(): string + { + return $this->token; + } + + /** + * Token setter. + * + * @param string $token + * + * @return $this + */ + public function setToken(string $token): self + { + $this->token = $token; + + return $this; + } + + /** + * API Base URI getter. + * + * @return string + */ + public function getApiBaseUri(): string + { + return $this->apiBaseUri; + } + + /** + * API Base URI setter. + * + * @param string $apiBaseUri + * + * @return $this + */ + public function setApiBaseUri(string $apiBaseUri): self + { + $this->apiBaseUri = rtrim($apiBaseUri, '/'); + + return $this; + } + + /** + * Get HttpClient. + * + * @return HttpClient + */ + protected function httpClient(): HttpClient + { + return $this->http; + } + + /** + * Send text message. + * + * + * $params = [ + * 'chat_id' => '', + * 'text' => '', + * 'parse_mode' => '', + * 'disable_web_page_preview' => '', + * 'disable_notification' => '', + * 'reply_to_message_id' => '', + * 'reply_markup' => '', + * ]; + * + * + * @link https://core.telegram.org/bots/api#sendmessage + * + * @param array $params + * + * @throws CouldNotSendNotification + * + * @return ResponseInterface|null + */ + public function sendMessage(array $params): ?ResponseInterface + { + return $this->sendRequest('sendMessage', $params); + } + + /** + * Send File as Image or Document. + * + * @param array $params + * @param string $type + * @param bool $multipart + * + * @throws CouldNotSendNotification + * + * @return ResponseInterface|null + */ + public function sendFile(array $params, string $type, bool $multipart = false): ?ResponseInterface + { + return $this->sendRequest('send'.Str::studly($type), $params, $multipart); + } + + /** + * Send a Location. + * + * @param array $params + * + * @throws CouldNotSendNotification + * + * @return ResponseInterface|null + */ + public function sendLocation(array $params): ?ResponseInterface + { + return $this->sendRequest('sendLocation', $params); + } + + /** + * Send an API request and return response. + * + * @param string $endpoint + * @param array $params + * @param bool $multipart + * + * @throws CouldNotSendNotification + * + * @return ResponseInterface|null + */ + protected function sendRequest(string $endpoint, array $params, bool $multipart = false): ?ResponseInterface + { + if (blank($this->token)) { + throw CouldNotSendNotification::telegramBotTokenNotProvided('You must provide your telegram bot token to make any API requests.'); + } + + $apiUri = sprintf('%s/bot%s/%s', $this->apiBaseUri, $this->token, $endpoint); + + try { + return $this->httpClient()->post($apiUri, [ + $multipart ? 'multipart' : 'form_params' => $params, + ]); + } catch (ClientException $exception) { + throw CouldNotSendNotification::telegramRespondedWithAnError($exception); + } catch (Exception $exception) { + throw CouldNotSendNotification::couldNotCommunicateWithTelegram($exception); + } + } +} diff --git a/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramChannel.php b/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramChannel.php new file mode 100644 index 00000000..757a36c6 --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramChannel.php @@ -0,0 +1,68 @@ +telegram = $telegram; + } + + /** + * Send the given notification. + * + * @param mixed $notifiable + * @param Notification $notification + * + * @return null|array + * + * @throws CouldNotSendNotification + */ + public function send($notifiable, Notification $notification): ?array + { + $message = $notification->toTelegram($notifiable); + + if (is_string($message)) { + $message = TelegramMessage::create($message); + } + + if ($message->toNotGiven()) { + if (! $to = $notifiable->routeNotificationFor('telegram', $notification)) { + return null; + } + + $message->to($to); + } + + $params = $message->toArray(); + + if ($message instanceof TelegramMessage) { + $response = $this->telegram->sendMessage($params); + } elseif ($message instanceof TelegramLocation) { + $response = $this->telegram->sendLocation($params); + } elseif ($message instanceof TelegramFile) { + $response = $this->telegram->sendFile($params, $message->type, $message->hasFile()); + } else { + return null; + } + + return json_decode($response->getBody()->getContents(), true); + } +} diff --git a/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramFile.php b/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramFile.php new file mode 100644 index 00000000..4366d7e4 --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramFile.php @@ -0,0 +1,231 @@ +content($content); + $this->payload['parse_mode'] = 'Markdown'; + } + + /** + * Notification message (Supports Markdown). + * + * @param string $content + * + * @return $this + */ + public function content(string $content): self + { + $this->payload['caption'] = $content; + + return $this; + } + + /** + * Add File to Message. + * + * Generic method to attach files of any type based on API. + * + * @param string $file + * @param string $type + * @param string|null $filename + * + * @return $this + */ + public function file($file, string $type, string $filename = null): self + { + $this->type = $type; + + $isLocalFile = $this->isReadableFile($file); + + if ($filename !== null || $isLocalFile) { + $this->payload['file'] = [ + 'filename' => $filename, + 'name' => $type, + 'contents' => $isLocalFile ? fopen($file, 'rb') : $file, + ]; + } else { + $this->payload[$type] = $file; + } + + return $this; + } + + /** + * Attach an image. + * + * Use this method to send photos. + * + * @param string $file + * + * @return $this + */ + public function photo(string $file): self + { + return $this->file($file, 'photo'); + } + + /** + * Attach an audio file. + * + * Use this method to send audio files, if you want Telegram clients to display them in the music player. + * Your audio must be in the .mp3 format. + * + * @param string $file + * + * @return $this + */ + public function audio(string $file): self + { + return $this->file($file, 'audio'); + } + + /** + * Attach a document or any file as document. + * + * Use this method to send general files. + * + * @param string $file + * @param string|null $filename + * + * @return $this + */ + public function document(string $file, string $filename = null): self + { + return $this->file($file, 'document', $filename); + } + + /** + * Attach a video file. + * + * Use this method to send video files, Telegram clients support mp4 videos. + * + * @param string $file + * + * @return $this + */ + public function video(string $file): self + { + return $this->file($file, 'video'); + } + + /** + * Attach an animation file. + * + * Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). + * + * @param string $file + * + * @return $this + */ + public function animation(string $file): self + { + return $this->file($file, 'animation'); + } + + /** + * Attach a voice file. + * + * Use this method to send audio files, if you want Telegram clients to display the file as a playable voice + * message. For this to work, your audio must be in an .ogg file encoded with OPUS. + * + * @param string $file + * + * @return $this + */ + public function voice(string $file): self + { + return $this->file($file, 'voice'); + } + + /** + * Attach a video note file. + * + * Telegram clients support rounded square mp4 videos of up to 1 minute long. + * Use this method to send video messages. + * + * @param string $file + * + * @return $this + */ + public function videoNote(string $file): self + { + return $this->file($file, 'video_note'); + } + + /** + * Determine there is a file. + * + * @return bool + */ + public function hasFile(): bool + { + return isset($this->payload['file']); + } + + /** + * Returns params payload. + * + * @return array + */ + public function toArray(): array + { + return $this->hasFile() ? $this->toMultipart() : $this->payload; + } + + /** + * Create Multipart array. + * + * @return array + */ + public function toMultipart(): array + { + $data = []; + foreach ($this->payload as $name => $contents) { + $data[] = ($name === 'file') ? $contents : compact('name', 'contents'); + } + + return $data; + } + + /** + * Determine if it's a regular and readable file. + * + * @param string $file + * + * @return bool + */ + protected function isReadableFile(string $file): bool + { + return is_file($file) && is_readable($file); + } +} diff --git a/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramLocation.php b/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramLocation.php new file mode 100644 index 00000000..b3853a09 --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramLocation.php @@ -0,0 +1,65 @@ +latitude($latitude); + $this->longitude($longitude); + } + + /** + * Location's latitude. + * + * @param float|string $latitude + * + * @return $this + */ + public function latitude($latitude): self + { + $this->payload['latitude'] = $latitude; + + return $this; + } + + /** + * Location's latitude. + * + * @param float|string $longitude + * + * @return $this + */ + public function longitude($longitude): self + { + $this->payload['longitude'] = $longitude; + + return $this; + } +} diff --git a/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramMessage.php b/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramMessage.php new file mode 100644 index 00000000..c23326d8 --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramMessage.php @@ -0,0 +1,49 @@ +content($content); + $this->payload['parse_mode'] = 'Markdown'; + } + + /** + * Notification message (Supports Markdown). + * + * @param string $content + * + * @return $this + */ + public function content(string $content): self + { + $this->payload['text'] = $content; + + return $this; + } +} diff --git a/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramServiceProvider.php b/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramServiceProvider.php new file mode 100644 index 00000000..7239f42b --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/src/TelegramServiceProvider.php @@ -0,0 +1,28 @@ +app->when(TelegramChannel::class) + ->needs(Telegram::class) + ->give(static function () { + return new Telegram( + config('services.telegram-bot-api.token'), + app(HttpClient::class), + config('services.telegram-bot-api.base_uri') + ); + }); + } +} diff --git a/conf/site/vendor/laravel-notification-channels/telegram/src/Traits/HasSharedLogic.php b/conf/site/vendor/laravel-notification-channels/telegram/src/Traits/HasSharedLogic.php new file mode 100644 index 00000000..d0e101bd --- /dev/null +++ b/conf/site/vendor/laravel-notification-channels/telegram/src/Traits/HasSharedLogic.php @@ -0,0 +1,119 @@ +payload['chat_id'] = $chatId; + + return $this; + } + + /** + * Add an inline button. + * + * @param string $text + * @param string $url + * @param int $columns + * + * @return $this + */ + public function button($text, $url, $columns = 2): self + { + $this->buttons[] = compact('text', 'url'); + + $this->payload['reply_markup'] = json_encode([ + 'inline_keyboard' => array_chunk($this->buttons, $columns), + ]); + + return $this; + } + + /** + * Send the message silently. + * Users will receive a notification with no sound. + * + * @param bool $disableNotification + * @return $this + */ + public function disableNotification(bool $disableNotification = true): self + { + $this->payload['disable_notification'] = $disableNotification; + + return $this; + } + + /** + * Additional options to pass to sendMessage method. + * + * @param array $options + * + * @return $this + */ + public function options(array $options): self + { + $this->payload = array_merge($this->payload, $options); + + return $this; + } + + /** + * Determine if chat id is not given. + * + * @return bool + */ + public function toNotGiven(): bool + { + return ! isset($this->payload['chat_id']); + } + + /** + * Get payload value for given key. + * + * @param string $key + * + * @return mixed|null + */ + public function getPayloadValue(string $key) + { + return $this->payload[$key] ?? null; + } + + /** + * Returns params payload. + * + * @return array + */ + public function toArray(): array + { + return $this->payload; + } + + /** + * Convert the object into something JSON serializable. + * + * @return mixed + */ + public function jsonSerialize() + { + return $this->toArray(); + } +}