antonosipov / telegram-common
该包最新版本(0.1.5)没有提供许可证信息。
0.1.5
2023-07-24 11:05 UTC
Requires
- guzzlehttp/guzzle: ^7.7
- illuminate/collections: ^10.12
- illuminate/console: ^10.12
- illuminate/contracts: ^10.12
- illuminate/http: ^10.12
- illuminate/support: ^10.12
README
如何安装
composer require antonosipov/telegram-common
php artisan vendor:publish --provider="Antonosipov\TelegramCommon\Providers\TelegramCommonServiceProvider"
添加到 .env
TELEGRAM_TOKEN=<token_here>
或在 config/telegram-common.php
中更改环境变量
配置
您可以轻松地从请求中获取Telegram实体,例如echo-bot
namespace App\Http\Controllers; use Antonosipov\TelegramCommon\Message; use Antonosipov\TelegramCommon\TelegramService; use Illuminate\Http\Request; class TelegramHookController extends Controller { public function __construct(protected TelegramService $telegramService) { } public function hook(Request $request) { $message = Message::fromRequest($request); if($message){ $this->telegramService->sendMessage($message->getChat()->getId(), $message->getText()); } } }