hybridgram/tgbot-laravel
最新稳定版本:0.2.0
Composer 安装命令:
composer require hybridgram/tgbot-laravel
包简介
Super fast package for Laravel to build Telegram bots powered by Go
README 文档
README
Laravel toolkit for fast Telegram bots creation with Go-powered webhook updating.
Quick start
composer require hybridgram/tgbot-laravel
php artisan vendor:publish --provider="HybridGram\Providers\TelegramServiceProvider"
Set BOT_TOKEN (and optional BOT_ID, BOT_NAME) in .env. Routing defaults to routes/telegram.php.
Minimal working example
routes/telegram.php
<?php use HybridGram\Facades\TelegramRouter; use HybridGram\Core\Routing\RouteData\TextMessageData; use HybridGram\Core\Routing\RouteData\PollData; use HybridGram\Telegram\Poll\PollType; use HybridGram\Telegram\TelegramBotApi; TelegramRouter::group(['for_bot' => 'main'], function (\HybridGram\Core\Routing\TelegramRouteBuilder $builder) { $builder->onTextMessage(function (TextMessageData $message) { $api = app(TelegramBotApi::class); $api->sendMessage($message->getChatId(), "Echo: {$message->text}"); }); // you can use any of route // $builder->onPoll(function (PollData $poll) { // $api = app(TelegramBotApi::class); // $api->sendMessage( // $poll->getChatId(), // "Poll received ({$poll->poll->type}) with " . count($poll->poll->options) . " options" // ); // }, pollType: PollType::REGULAR); });
Run polling in dev:
php artisan hybridgram:polling --hot-reload
Go module (go-proxy) and async updates for production
The bundled ./vendor/bin/tgook script downloads the go-proxy binary (from hybridgram/go-proxy) and runs it with your .env to stream updates via a high-performance Go worker. Use it when you need long-lived, asynchronous update handling without blocking PHP:
# install & run go-proxy with your .env
php ./vendor/bin/tgook
Key features
- Typed router covering Telegram updates (
onMessage,onPoll, callbacks, media, etc.). - Hot-reload polling for fast local development.
- Queue-aware outbound sending with rate limiting and HIGH/LOW priorities.
- Artisan helpers: set/delete webhook, list routes, configure bot settings.
Docs
- Supported update handlers:
telegram-update-types.md
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-14
