mirakhamidov / yii2-bot-telegram
Telegram机器人
0.1.1
2024-01-06 16:21 UTC
Requires
- php: ^7.1.3|^8.0
This package is auto-updated.
Last update: 2024-09-06 17:48:57 UTC
README
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
php composer.phar require mirkhamidov/yii2-bot-telegram "*"
或者在你的 composer.json
文件的require部分添加
"mirkhamidov/yii2-bot-telegram": "*"
使用方法
首先添加到 config.php
<?php 'components' => [ 'telegram' => [ 'class' => 'mirkhamidov\telegramBot\TelegramBot', 'botToken' => 'TOKEN HERE', ] ] ?>
安装扩展后,只需在代码中使用即可
<?php Yii::$app->telegram->sendMessage('Message'); ?>
通过
<?php Yii::$app->telegram->sendMessage('Message with inline keyboard', $chatId, [ 'reply_markup' => json_encode([ 'inline_keyboard'=>[ [ ['text'=>"refresh",'callback_data'=> time()] ] ] ]), ] ?>
通过
<?php Yii::$app->telegram->sendPhoto('/app/pattern2.jpg', $chatId, [ 'caption' => 'some text', ]); ?>
待办事项
- 日志记录
PS: 受aki/yii2-bot-telegram启发