The module is for developers. Add some telegram integration for your site.

New features of 2.0.x branch:

  • Value object instead of a lot of parameters in service function
  • Webform handler to send webform data to telegram
  • Send to custom endpoint
  • Queue as option (delay send)

2.0.x Send to telegram bot example

use Drupal\telegram_api\ValueObject\TelegramMessage;

$message = new TelegramMessage(
  text: 'Hello from Drupal!',
  token: '618218965:AAG...',
  chatId: '12345678',
);

\Drupal::service('telegram_api.service')?->sendToTelegramBot($message);

2.0.x Send to queue example

use Drupal\telegram_api\ValueObject\TelegramMessage;

$message = new TelegramMessage(
  text: 'Hello from Drupal!',
  token: '618218965:AAG...',
  chatId: '12345678',
);

\Drupal::service('telegram_api.service')?->queue($message);

And then drush queue:run telegram_api_queue

1.0.x Send to telegram bot example

$result = \Drupal::service('telegram_api.service')->sendToTelegramBot($text, $token, $chat_id);
if ($result !== TRUE) {
  \Drupal::logger('My module')->error($result);
}

Project information

Releases