PHPackages                             tourze/wechat-work-intercept-rule-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tourze/wechat-work-intercept-rule-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

tourze/wechat-work-intercept-rule-bundle
========================================

企业微信聊天敏感词拦截规则管理组件

0.1.0(6mo ago)00MITPHPCI failing

Since Jun 4Pushed 4mo agoCompare

[ Source](https://github.com/tourze/wechat-work-intercept-rule-bundle)[ Packagist](https://packagist.org/packages/tourze/wechat-work-intercept-rule-bundle)[ RSS](/packages/tourze-wechat-work-intercept-rule-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (43)Versions (3)Used By (0)

WechatWorkInterceptRuleBundle
=============================

[](#wechatworkinterceptrulebundle)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b51d05db54fd613655a3264b04a948f3e2391c54bcf1eb3e19a273914b20c6ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f7765636861742d776f726b2d696e746572636570742d72756c652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/wechat-work-intercept-rule-bundle)[![PHP Version Require](https://camo.githubusercontent.com/5caedc2c307c99a23da4a473f2e4e63eeda509f9cc3d30d43a8ca48335e586ae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f7765636861742d776f726b2d696e746572636570742d72756c652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/wechat-work-intercept-rule-bundle)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Total Downloads](https://camo.githubusercontent.com/0c547ff678ca18e79b1ff305a9cbf3a9277fcebbae25004dabd9a19cdc5adda1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f7765636861742d776f726b2d696e746572636570742d72756c652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/wechat-work-intercept-rule-bundle)[![Code Coverage](https://camo.githubusercontent.com/6ce0146325478eb7cebae4cc6139b2af2c161735dd0e3c6ff6802f2c5a708179/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f7068702d6d6f6e6f7265706f3f7374796c653d666c61742d737175617265)](https://codecov.io/gh/tourze/php-monorepo)

A Symfony bundle for managing WeChat Work sensitive word intercept rules. This bundle provides functionality to synchronize, manage, and apply sensitive word filtering rules for WeChat Work applications.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Entities](#entities)
        - [InterceptRule Entity](#interceptrule-entity)
        - [InterceptType Enum](#intercepttype-enum)
    - [Commands](#commands)
        - [Sync Intercept Rules](#sync-intercept-rules)
    - [API Requests](#api-requests)
    - [Repository](#repository)
    - [Event Listeners](#event-listeners)
- [Advanced Usage](#advanced-usage)
    - [Custom Rule Processing](#custom-rule-processing)
    - [Bulk Operations](#bulk-operations)
    - [Integration with External Systems](#integration-with-external-systems)
- [Database Schema](#database-schema)
- [Cron Job](#cron-job)
- [Dependencies](#dependencies)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)
- [References](#references)

Features
--------

[](#features)

- **Intercept Rule Management**: Create, update, and delete sensitive word rules
- **Automatic Synchronization**: Sync rules from WeChat Work API automatically
- **Flexible Rule Types**: Support for warning-only and intercept-and-block rule types
- **Cron Job Integration**: Automatic rule synchronization every 10 minutes
- **Multi-Agent Support**: Manage rules across multiple WeChat Work agents
- **Doctrine Integration**: Full ORM support with entities and repositories

Installation
------------

[](#installation)

```
composer require tourze/wechat-work-intercept-rule-bundle
```

Configuration
-------------

[](#configuration)

Add the bundle to your `config/bundles.php`:

```
return [
    // ...
    WechatWorkInterceptRuleBundle\WechatWorkInterceptRuleBundle::class => ['all' => true],
];
```

Usage
-----

[](#usage)

### Entities

[](#entities)

#### InterceptRule Entity

[](#interceptrule-entity)

The main entity for managing sensitive word rules:

```
use WechatWorkInterceptRuleBundle\Entity\InterceptRule;
use WechatWorkInterceptRuleBundle\Enum\InterceptType;

// Create a new intercept rule
$rule = new InterceptRule();
$rule->setName('Marketing Keywords');
$rule->setWordList(['spam', 'promotion', 'advertisement']);
$rule->setInterceptType(InterceptType::WARN);
```

#### InterceptType Enum

[](#intercepttype-enum)

Defines the action to take when sensitive words are detected:

- `InterceptType::WARN`: Warning and block sending (警告并拦截发送)
- `InterceptType::NOTICE`: Warning only (仅警告)

### Commands

[](#commands)

#### Sync Intercept Rules

[](#sync-intercept-rules)

Synchronize sensitive word rules from WeChat Work API:

```
php bin/console wechat-work:sync-intercept-rule
```

This command:

- Fetches all intercept rules from WeChat Work API
- Creates or updates local rule entities
- Runs automatically every 10 minutes via cron job
- Supports multiple agents and corporations

### API Requests

[](#api-requests)

The bundle provides request classes for WeChat Work API integration:

```
use WechatWorkInterceptRuleBundle\Request\GetInterceptRuleListRequest;
use WechatWorkInterceptRuleBundle\Request\GetInterceptRuleDetailRequest;
use WechatWorkInterceptRuleBundle\Request\AddInterceptRuleRequest;
use WechatWorkInterceptRuleBundle\Request\UpdateInterceptRuleRequest;
use WechatWorkInterceptRuleBundle\Request\DeleteInterceptRuleRequest;

// Get list of intercept rules
$request = new GetInterceptRuleListRequest();
$request->setAgent($agent);
$response = $workService->request($request);

// Get detailed rule information
$detailRequest = new GetInterceptRuleDetailRequest();
$detailRequest->setAgent($agent);
$detailRequest->setRuleId('rule_id');
$detail = $workService->request($detailRequest);
```

### Repository

[](#repository)

Use the repository for database operations:

```
use WechatWorkInterceptRuleBundle\Repository\InterceptRuleRepository;

// Inject the repository
public function __construct(
    private InterceptRuleRepository $ruleRepository
) {}

// Find rules by corporation
$rules = $this->ruleRepository->findBy(['corp' => $corp]);

// Find rule by remote rule ID
$rule = $this->ruleRepository->findOneBy([
    'corp' => $corp,
    'ruleId' => 'remote_rule_id'
]);
```

### Event Listeners

[](#event-listeners)

The bundle includes event subscribers for handling rule-related events:

```
use WechatWorkInterceptRuleBundle\EventSubscriber\InterceptRuleListener;
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Rule Processing

[](#custom-rule-processing)

You can create custom processors for handling specific rule types:

```
use WechatWorkInterceptRuleBundle\Entity\InterceptRule;

class CustomRuleProcessor
{
    public function processRule(InterceptRule $rule): bool
    {
        // Custom processing logic
        $wordList = $rule->getWordList();
        $interceptType = $rule->getInterceptType();

        // Implement your custom rule processing
        return $this->applyCustomLogic($wordList, $interceptType);
    }
}
```

### Bulk Operations

[](#bulk-operations)

For managing large numbers of rules:

```
use WechatWorkInterceptRuleBundle\Repository\InterceptRuleRepository;
use Doctrine\ORM\EntityManagerInterface;

class BulkRuleManager
{
    public function __construct(
        private InterceptRuleRepository $repository,
        private EntityManagerInterface $entityManager
    ) {}

    public function bulkUpdate(array $rules): void
    {
        foreach ($rules as $ruleData) {
            $rule = $this->repository->findOneBy(['ruleId' => $ruleData['id']]);
            if ($rule) {
                $rule->setWordList($ruleData['wordList']);
                $rule->setInterceptType($ruleData['interceptType']);
            }
        }

        $this->entityManager->flush();
    }
}
```

### Integration with External Systems

[](#integration-with-external-systems)

Example of integrating with external content filtering systems:

```
use WechatWorkInterceptRuleBundle\Entity\InterceptRule;

class ExternalFilterIntegration
{
    public function syncWithExternalSystem(InterceptRule $rule): void
    {
        $externalData = [
            'rule_id' => $rule->getRuleId(),
            'keywords' => $rule->getWordList(),
            'action' => $rule->getInterceptType()->value,
        ];

        // Send to external system
        $this->externalClient->updateRule($externalData);
    }
}
```

Database Schema
---------------

[](#database-schema)

The bundle creates the following table:

```
CREATE TABLE wechat_work_intercept_rule (
    id INT AUTO_INCREMENT PRIMARY KEY,
    corp_id INT NOT NULL,
    agent_id INT NOT NULL,
    rule_id VARCHAR(60),
    name VARCHAR(20) NOT NULL,
    word_list JSON NOT NULL,
    intercept_type VARCHAR(1) NOT NULL,
    applicable_user_list JSON NOT NULL,
    applicable_department_list JSON NOT NULL,
    is_sync BOOLEAN NOT NULL DEFAULT FALSE,
    create_time DATETIME NOT NULL,
    update_time DATETIME NOT NULL,
    created_by INT,
    updated_by INT
);
```

Cron Job
--------

[](#cron-job)

The bundle automatically registers a cron job to sync rules every 10 minutes:

```
#[AsCronTask(expression: '*/10 * * * *')]
```

Dependencies
------------

[](#dependencies)

This bundle requires:

- PHP 8.1+
- Symfony 6.4+
- Doctrine ORM 3.0+
- WeChat Work Bundle
- Various Tourze utility bundles

Testing
-------

[](#testing)

Run the test suite:

```
./vendor/bin/phpunit packages/wechat-work-intercept-rule-bundle/tests
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please submit pull requests or create issues for bugs and feature requests.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

References
----------

[](#references)

- [WeChat Work API Documentation](https://developer.work.weixin.qq.com/document/path/96346)
- [Symfony Bundle Documentation](https://symfony.com/doc/current/bundles.html)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance72

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~159 days

Total

2

Last Release

180d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (4 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-wechat-work-intercept-rule-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-wechat-work-intercept-rule-bundle/health.svg)](https://phpackages.com/packages/tourze-wechat-work-intercept-rule-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M650](/packages/sylius-sylius)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
