PHPackages                             269995848/qqrobot - 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. [API Development](/categories/api)
4. /
5. 269995848/qqrobot

ActiveLibrary[API Development](/categories/api)

269995848/qqrobot
=================

php library for qq

36272[1 issues](https://github.com/188700679/qqRobot/issues)PHP

Since Nov 11Pushed 5y ago3 watchersCompare

[ Source](https://github.com/188700679/qqRobot)[ Packagist](https://packagist.org/packages/269995848/qqrobot)[ RSS](/packages/269995848-qqrobot/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

QQRobot是一个轻量级,高扩展的QQ机器人的php开源库,

原先的github被封了,

批量发送功能慎用,小心封号

===============

> php的运行环境要求PHP7+。

> 他依赖coolq,如果你不熟悉coolq，我提供了[快捷安装](https://github.com/188700679/yjscript/blob/master/coolq%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B.txt)

> 个人[实践代码](https://github.com/188700679/tp5_qqrobot)

> qqRobot的权限依赖QQ的权限，尽量你的qq机器人在群内或是其他地方有最高权限（管理员），避免某些群管理功能失效

安装
==

[](#安装)

```
composer require 269995848/qqrobot dev-master

```

它
=

[](#它)

1.消息委托

2.消息代理

3.发送图片,文字

4.消息群发

5.发送音频

6.组件化开发

7.Q群管理,列表获取等

8.自动解析

9.默认异步发送

10.智能对话,图片检黄(内置组件)//图片检黄组件剔除，因为并发性太低了

11.事件监听

HOW TO DO IT
============

[](#how-to-do-it)

#### 全局配置

[](#全局配置)

```
 $config=[
    'proxyQQ'       =>'', //消息事件委托转发QQ
    'host'          =>'127.0.0.1:5700', //监听地址+端口,要配置内网地址,一般是ens0,某些服务器是ens33
    'cookies'       =>false,
    'httpOrS'       =>true,
    'isLog'         =>true, //是否开启日志,默认生成在类库 'qqrobot.log'
    'listenQQRobot' =>true, //是否监听
    'token'         =>'',
    'allowFriend'   =>true,  //是否允许加我为好友
    'allowGroup'    =>true,  //是否允许加我入群
    'atParse'       =>true,  //是否解析at我
    'logFile'       =>'',    //日志文件命名,需要有权限
    'self_qq'       =>'2442459484'  //机器人QQ号
];

$server=new Server($config);

```

#### 动态配置

[](#动态配置)

> 他是局部配置,优先级比全局配置高,但只存在当前server实例中,应用场景不同

```
use QQRobot\Server;

$server=new Server();
$server->isLog=false;   //关闭日志记录

```

#### 接受事件消息

[](#接受事件消息)

```
use QQRobot\Server;

$server=new Server();
$response=$server->response();

```

#### 对事件的产生者回应

[](#对事件的产生者回应)

> 对当前的事件者回应,必须依赖当前的server实例

```
use QQRobot\Server;
use QQRobot\QQRobotConst;
use QQRobot\Client;

$server=new Server();
$response=$server->response();

if(isset($response->notice_type)){
    if(
        $response->user_id!=$server->config->self_qq
        &&
        ($response->sub_type== QQRobotConst::APPROVE)
        &&
        ($response->notice_type==QQRobotConst::GROUP_INCREASE)
    ){
        $msg='128552',  //可以附带emoji,(不必)
                'at'=>'1234567',//是否@qq1234567,如果要@当前事件产生者,则'at'=>'at'.(不必)
                'img'=>'绝对路径.png',  //(不必)如果你安装是cqa,则不支持这个功能
                 'rec'=>'音频绝对路径' //不必 如果你安装是cqa,则不支持这个功能
                 ],
                 [
                 'msg'=>$msg, //回应消息,(必填)
                 'emoji'=>'128552',  //可以附带emoji,(不必)
                 'at'=>'1234567',//是否@qq1234567,如果要@当前事件产生者,则'at'=>'at'.(不必)
                 'img'=>'绝对路径.png',  //(不必)如果你安装是cqa,则不支持这个功能
                  'rec'=>'音频绝对路径' //不必 如果你安装是cqa,则不支持这个功能
                  ],

             ]
        });
    }
}

```

#### 组件化开发

[](#组件化开发)

> 组件化不支持动态配置

```
use QQRobot\Load;

$load=new  Load($config);  //($config 不必) 默认会按照当前server实例的配置进行读取
$load->addObserver(new Leave());
$load->addObserver(new Join());
$load->addObserver(new AtMe());
$load->loader();

```

#### 主动发送消息

[](#主动发送消息)

> 主动发送消息事件,不依赖当前server实例

```
use QQRobot\Client;

$client=new Client();
$client->on('msg',function(){
    return
        ['msg'=>'你从哪里来?',  //(必填)
         'emoji'=>'128552',   //(不必)
         'group'=>true,    //(必填) true:发送群里,false:私聊某人
         'qq'=>'623582882',  //(必填) 群号/qq号
         'at'=>'623582882'  //(不必)是否@,私聊则无效
         'img'=>'绝对路径.png', //不必，如果你安装是cqa,则不支持这个功能
         'rec'=>'音频绝对路径' //不必，如果你安装是cqa,则不支持这个功能
     ];

});

```

#### 群发

[](#群发)

```
 public function time(){
        $client=new Client($this->config);
        $msg="消息群发啦";

        $qun=['xxxx','xxxx','xxxx'];
        $emoji=rand(128512,128588);;
        $arr=[
            'msg'=>$msg,
            'emoji'=>$emoji,
            'group'=>'true',
            'qq'=>'',
            'img'=>'qqrobot_detail.png'
        ];

        $msg=[];

        foreach($qun as $v){
            $arr['qq']=$v;
            $msg[]=$arr;
        }

        $client->on('msg',function()use($msg){
            return $msg;
        });

    }

```

> server实例应在你的项目入口处调用,比如tp5默认是index/index/index

### 意思不意思是你的意思，我将会继续去维护下去，目前正在进行微信机器人开发

[](#意思不意思是你的意思我将会继续去维护下去目前正在进行微信机器人开发)

#### 微信

[](#微信)

[![Image text](https://camo.githubusercontent.com/45072c13d005b1481e5e8b1bab85d058a2554d0d834e8eae94127b120d648401/687474703a2f2f3133392e3232342e3130312e33363a38312f77782e706e67)](https://camo.githubusercontent.com/45072c13d005b1481e5e8b1bab85d058a2554d0d834e8eae94127b120d648401/687474703a2f2f3133392e3232342e3130312e33363a38312f77782e706e67)

#### 支付宝

[](#支付宝)

[![Image text](https://camo.githubusercontent.com/d41616f3f3f3a7d36d22660fcb3f5df6ebeccee905d1930bcd1154e45ede04b9/687474703a2f2f3133392e3232342e3130312e33363a38312f7a66622e706e67)](https://camo.githubusercontent.com/d41616f3f3f3a7d36d22660fcb3f5df6ebeccee905d1930bcd1154e45ede04b9/687474703a2f2f3133392e3232342e3130312e33363a38312f7a66622e706e67)

感谢捐赠者： 消逝，随心所欲，`andYes，忧愁的程序员，大致\*如此，人生搬砖工

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity31

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.

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/269995848-qqrobot/health.svg)

```
[![Health](https://phpackages.com/badges/269995848-qqrobot/health.svg)](https://phpackages.com/packages/269995848-qqrobot)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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