kavalar/telegram_bot

Telegram Bot Service

Maintainers

👁 apuc

Package info

github.com/apuc/telegram_bot

pkg:composer/kavalar/telegram_bot

Statistics

Installs: 37

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

0.2 2021-08-25 14:10 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT f741e68a756c33f5e2f330c85e63ad1b9f301f42

  • Ivaniv Anton <anton.o.ivaniv.woop@gmail.com>

This package is auto-updated.

Last update: 2026-06-26 00:51:38 UTC


README

Telegram Bot Service

TelegramBotService

Methods

sendMessageTo($chat_id, $message)

Use this method to send message to given chat.

$bot = new TelegramBotService($token);
$result = $bot->sendMessageTo($chat_id, $message);

BotNotificationTemplateProcessor

Methods

__construct($templates)

$templates is associative array such format

[
 'template_name' => "Hello ~name~"
];

Where ~name~ is parameter which could be rendered by renderTemplate method

renderTemplate($template_name, $parameters)

Returns rendered template

$args is associative array such format

[
 'name' => 'Jhon'
];

Throws NoSuchParameterException, NoSuchTemplateException,

Example

$bot = new TelegramBotService($token);

$templates = [
 'example' => "Hello ~name~"
];
$attributes = [
 'name' => 'Jhon'
];

$templateProcessor = new BotNotificationTemplateProcessor($templates);
$message = $templateProcessor->renderTemplate('example', $attributes);

$result = $bot->sendMessageTo($chat_id, $message);

Watch full example at example.php