mirkhamidov / yii2-bot-telegram
bot for telegram
Installs: 216
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: ^7.1.3|^8.0
This package is auto-updated.
Last update: 2024-12-06 18:33:31 UTC
README
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require mirkhamidov/yii2-bot-telegram "*"
or add
"mirkhamidov/yii2-bot-telegram": "*"
to the require section of your composer.json
file.
Usage
first add to config.php
<?php 'components' => [ 'telegram' => [ 'class' => 'mirkhamidov\telegramBot\TelegramBot', 'botToken' => 'TOKEN HERE', ] ] ?>
Once the extension is installed, simply use it in your code by :
<?php Yii::$app->telegram->sendMessage('Message'); ?>
send message width inline keyboard by:
<?php Yii::$app->telegram->sendMessage('Message with inline keyboard', $chatId, [ 'reply_markup' => json_encode([ 'inline_keyboard'=>[ [ ['text'=>"refresh",'callback_data'=> time()] ] ] ]), ] ?>
send photo by :
<?php Yii::$app->telegram->sendPhoto('/app/pattern2.jpg', $chatId, [ 'caption' => 'some text', ]); ?>
TODO
- Logging
PS: Inspired by aki/yii2-bot-telegram