Vbot是基于微信 web API 实现的机器人,通过实现匿名函数能够实现多种自定义的效果
例如:
- 消息转发
- 红包提醒(有点鸡肋)
- 留言统计
- 自定义回复
- 防撤回
- 特殊关键词触发事件
等等,这里就不一一列举,可以参考 详细例子
安装
composer require hanson/vbot
使用
require_once __DIR__ . './../vendor/autoload.php'; use Hanson\Vbot\Foundation\Vbot; function reply($reply){ return http()->post('http://www.tuling123.com/openapi/api', [ 'key' => 'your tuling api key', 'info' => $reply ], true)['text']; } $robot->server->setMessageHandler(function ($message) { // 文字信息 if ($message instanceof Text) { // 联系人自动回复 if ($message->fromType === 'Contact') { return reply($message->content); // 群组 @我回复 } elseif ($message->fromType === 'Group' && $message->isAt) { return reply($message->content); } } }); $robot->server->run(); 项目地址:https://github.com/hanson/vbot
欢迎大家提交 issue 和 PR 让 vbot 更加完善
也可以加我刚新建的 QQ 群进行交流: 492548647
