telegram_api
114 sites
Security covered
The module is for developers. Add some telegram integration for your site.
2.0.x version has value object instead of a lot of parameters.
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);
1.0.x Send to telegram bot example (without telegram proxy)
$result = \Drupal::service('telegram_api.service')->sendToTelegramBot($text, $token, $chat_id);
if ($result !== TRUE) {
\Drupal::logger('My module')->error($result);
}1.0.x Send to telegram bot example (with telegram proxy)
$result = \Drupal::service('telegram_api.service')->sendToTelegramBot($text, $token, $chat_id, TRUE, $proxy_server, $proxy_login, $proxy_pass);
if ($result !== TRUE) {
\Drupal::logger('My module')->error($result);
}