Back to Deployer

Telegram Recipe

docs/contrib/telegram.md

8.0.33.4 KB
Original Source
<!-- DO NOT EDIT THIS FILE! --> <!-- Instead edit contrib/telegram.php --> <!-- Then run bin/docgen -->

Telegram Recipe

php
require 'contrib/telegram.php';

Source

Installing

  1. Create telegram bot with BotFather and grab the token provided
  2. Send /start to your bot and open https://api.telegram.org/bot{$TELEGRAM_TOKEN_HERE}/getUpdates
  3. Take chat_id from response Add hook on deploy:
php
before('deploy', 'telegram:notify');

Configuration

  • telegram_token – telegram bot token, required
  • telegram_chat_id — chat ID to push messages to
  • telegram_proxy - proxy connection string in CURLOPT_PROXY form like:
    http://proxy:80
    socks5://user:password@host:3128
    
  • telegram_title – the title of application, default {{application}}
  • telegram_text – notification message template
    _{{user}}_ deploying `{{what}}` to *{{where}}*
    
  • telegram_success_text – success template, default:
    Deploy to *{{where}}* successful
    
  • telegram_failure_text – failure template, default:
    Deploy to *{{where}}* failed
    

Usage

If you want to notify only about beginning of deployment add this line only:

php
before('deploy', 'telegram:notify');

If you want to notify about successful end of deployment add this too:

php
after('deploy:success', 'telegram:notify:success');

If you want to notify about failed deployment add this too:

php
after('deploy:failed', 'telegram:notify:failure');


## Configuration
### telegram_title
[Source](https://github.com/deployphp/deployer/blob/master/contrib/telegram.php#L65)

Title of project

```php title="Default value"
return get('application', 'Project');

telegram_token

Source

Telegram settings :::info Required Throws exception if not set. :::

telegram_chat_id

Source

:::info Required Throws exception if not set. :::

telegram_url

Source

php
return 'https://api.telegram.org/bot' . get('telegram_token') . '/sendmessage';

telegram_text

Source

Deploy message

php
'_{{user}}_ deploying `{{what}}` to *{{where}}*'

telegram_success_text

Source

php
'Deploy to *{{where}}* successful'

telegram_failure_text

Source

php
'Deploy to *{{where}}* failed'

Tasks

telegram:notify {#telegram-notify}

Source

Notifies Telegram.

telegram:notify:success {#telegram-notify-success}

Source

Notifies Telegram about deploy finish.

telegram:notify:failure {#telegram-notify-failure}

Source

Notifies Telegram about deploy failure.