Coder Social home page Coder Social logo

vbot's Introduction

安装

环境要求

  • PHP >= 5.6

安装

1、composer

composer require hanson/vbot

然后执行php example/index.php

PS:运行后二维码将保存于设置的缓存目录,命名为qr.png,控制台也会显示二维码,扫描即可(linux用户请确保已经打开ANSI COLOR)

警告!执行前请先查看index.php的代码,注释掉你认为不需要的代码,避免对其他人好友造成困扰

文档

详细文档在wiki

例子

所有类型例子

红包提醒

轰炸消息到某群名

消息转发

自定义处理器

一键拜年

聊天操作

基本使用

// 图灵API自动回复
require_once __DIR__ . './../vendor/autoload.php';

use Hanson\Vbot\Foundation\Vbot;
use Hanson\Vbot\Message\Entity\Message;
use Hanson\Vbot\Message\Entity\Text;

$robot = new Vbot([
    'tmp' => '/path/to/tmp/', # 用于生成登录二维码以及文件保存
    'debug' => true # 用于是否输出用户组的json
]);

// 图灵自动回复
function reply($str){
    return http()->post('http://www.tuling123.com/openapi/api', [
        'key' => '1dce02aef026258eff69635a06b0ab7d',
        'info' => $str
    ], true)['text'];

}

$robot->server->setMessageHandler(function($message){
    // 文字信息
    if ($message instanceof Text) {
        /** @var $message Text */
        // 联系人自动回复
        if ($message->fromType === 'Contact') {
            return reply($message->content);
            // 群组@我回复
        } elseif ($message->fromType === 'Group' && $message->isAt) {
            return reply($message->content);
        }
    }
});

$robot->server->run();

to do list

  • 消息处理

    • 文字
    • 图片
    • 语音
    • 位置
    • 视频
    • 撤回
    • 表情
    • 红包
    • 转账
    • 名片
    • 好友验证
    • 分享
    • 公众号推送
    • 新好友
    • 群变动(增加成员,移除成员,更改群名)
    • 小程序
  • 消息存储

    • 语音
    • 图片
    • 视频
    • 表情
  • 消息发送

    • 发送文字
    • 发送图片
    • 发送表情
    • 发送视频
  • 群操作

    • 创建群
    • 把某人踢出群
    • 邀请好友加入群
    • 修改群名称
  • 好友操作

    • 给好友添加备注
    • 通过好友验证
  • 聊天窗口操作

    • 置顶聊天会话
    • 取消聊天会话指定
  • 命令行操作信息发送

参考项目

lbbniu/WebWechat

littlecodersh/ItChat

感谢楼上两位作者曾对本人耐心解答

liuwons/wxBot 参考了整个微信的登录流程与消息处理

问题和建议

有问题或者建议都可以提issue

或者加入我新建的QQ群:492548647

vbot's People

Contributors

hanson avatar zhuanxuhit avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.