tourze / lark-custom-bot-bundle
飞书自定义机器人集成包
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/lark-custom-bot-bundle
Requires
- ext-json: *
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/orm: ^3.0
- doctrine/persistence: ^4.1
- easycorp/easyadmin-bundle: ^4
- knplabs/knp-menu: ^3.7
- monolog/monolog: ^3.1
- psr/log: ^3|^2|^1
- symfony/cache: ^7.3
- symfony/cache-contracts: ^3
- symfony/config: ^7.3
- symfony/dependency-injection: ^7.3
- symfony/doctrine-bridge: ^7.3
- symfony/event-dispatcher: ^7.3
- symfony/framework-bundle: ^7.3
- symfony/http-client-contracts: ^3.6
- symfony/http-kernel: ^7.3
- symfony/lock: ^7.3
- symfony/property-access: ^7.3
- symfony/yaml: ^7.3
- tourze/arrayable: 1.*
- tourze/doctrine-async-insert-bundle: 1.0.*
- tourze/doctrine-indexed-bundle: 1.0.*
- tourze/doctrine-timestamp-bundle: 1.1.*
- tourze/doctrine-track-bundle: 1.1.*
- tourze/easy-admin-menu-bundle: 1.0.*
- tourze/enum-extra: 1.0.*
- tourze/http-client-bundle: 1.1.*
- yiisoft/json: ^1.0
Requires (Dev)
- doctrine/doctrine-fixtures-bundle: ^4.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
- tourze/bundle-dependency: 1.*
- tourze/phpunit-base: 1.*
- tourze/phpunit-doctrine-entity: 1.*
- tourze/phpunit-enum: 1.*
- tourze/phpunit-symfony-kernel-test: 1.0.*
- tourze/phpunit-symfony-unit-test: 1.*
- tourze/phpunit-symfony-web-test: 1.*
- tourze/symfony-aop-async-bundle: 1.0.*
- tourze/symfony-dependency-service-loader: 1.0.*
- tourze/symfony-runtime-context-bundle: 1.0.*
This package is auto-updated.
Last update: 2025-11-18 15:30:45 UTC
README
Introduction
This Symfony bundle enables integration and management of Lark (Feishu) custom bots, supporting multiple message types (text, image, share chat, post, interactive card) with unified entity management and automated message delivery.
Features
- Supports various Lark message types: text, image, share chat, post (rich text), interactive card
- Decoupled webhook configuration, allowing management of multiple bots
- Persistent message entities for traceability
- Automated message sending (entity persistence triggers push)
- Extensible entity design for easy customization
Requirements
- PHP >= 8.1
- Symfony >= 7.3
- Doctrine ORM >= 3.0
Installation
Install
composer require tourze/lark-custom-bot-bundle
Configuration
- Configure your database and run migrations.
- Register the bundle in
config/bundles.php:
LarkCustomBotBundle\LarkCustomBotBundle::class => ['all' => true],
- Optionally customize
services.yamlas needed.
Quick Start
Create a Webhook Configuration
$webhook = new WebhookUrl(); $webhook->setName('Notify Bot'); $webhook->setUrl('https://open.feishu.cn/open-apis/bot/v2/hook/xxx'); $webhook->setRemark('Main notification bot'); $webhook->setValid(true);
Send a Text Message
$text = new TextMessage(); $text->setWebhookUrl($webhook); $text->setContent('Hello, Lark bot!'); $entityManager->persist($text); $entityManager->flush(); // Message will be sent automatically, no manual send required
For image, post, and card messages, refer to the entity design documentation
Advanced Usage
Custom Message Types
You can extend the base AbstractMessage class to create custom message types:
use LarkCustomBotBundle\Entity\AbstractMessage; class CustomMessage extends AbstractMessage { public function getType(): string { return 'custom'; } public function toArray(): array { return [ 'msg_type' => $this->getType(), 'content' => [ // Your custom message content ], ]; } }
Webhook Management
Manage multiple webhook configurations for different scenarios:
// Development bot $devWebhook = new WebhookUrl(); $devWebhook->setName('Dev Notifications'); $devWebhook->setUrl('https://open.feishu.cn/open-apis/bot/v2/hook/dev-xxx'); // Production bot $prodWebhook = new WebhookUrl(); $prodWebhook->setName('Prod Alerts'); $prodWebhook->setUrl('https://open.feishu.cn/open-apis/bot/v2/hook/prod-xxx');
Event Listener Customization
The bundle includes an event listener that automatically sends messages. You can customize or disable this behavior in your services configuration.
Message Validation
All message entities include built-in validation constraints. Ensure your data passes validation before persisting:
use Symfony\Component\Validator\Validator\ValidatorInterface; $violations = $validator->validate($textMessage); if (count($violations) > 0) { // Handle validation errors }
Documentation
Contributing
- Issues and PRs are welcome
- Follow PSR-12 coding style
- Ensure tests pass before submitting
License
MIT License
Changelog
- 0.1.0: Initial release