Giter VIP home page Giter VIP logo

onebot-client's Introduction

OneBot Client

✨ 基于java开发的 OneBot 协议客户端✨


issues License

文档 | QuickStart

QuickStart

使用api进行请求

public class WebSocketClientTest {
    public static void sendApi(String[] args) throws Exception {
        LinkedBlockingQueue<String> blockingQueue = new LinkedBlockingQueue<>();//使用队列传输数据
        ModWebSocketClient service = ConnectFactory.createWebsocketClient(new BotConfig("ws://127.0.0.1:8080"),blockingQueue);
        service.create();//创建websocket客户端
        Bot oneBotClient = service.createBot();//创建机器人实例,以调用api
        oneBotClient.sendGroupMsg(123456, MsgUtils.builder().text("123").build(), true);//发送群消息
        GroupMemberInfoResp sender = oneBotClient.getGroupMemberInfo(123456, 123456, false).getData();//获取响应的群成员信息
        System.out.println(sender.toString());//打印
    }
}

事件监听示例

public class WebSocketClientTest {
    public static void eventListener(String[] args) throws Exception {
        LinkedBlockingQueue<String> blockingQueue = new LinkedBlockingQueue<>();//使用队列传输数据
        ModWebSocketClient service = ConnectFactory.createWebsocketClient(new BotConfig("ws://127.0.0.1:8080"),blockingQueue);
        service.create();//创建websocket客户端
        EventDispatchers dispatchers = new EventDispatchers(blockingQueue);//创建事件分发器
        GroupMessageListener groupMessageListener = new GroupMessageListener();//自定义监听规则
        groupMessageListener.addHandler("天气", new Handler<GroupMessageEvent>() {
            @Override
            public void handle(GroupMessageEvent groupMessage) {
                System.out.println(groupMessage);

            }
        });//匹配关键字监听
        dispatchers.addListener(groupMessageListener);//注册监听
        dispatchers.addListener(new SimpleListener<PrivateMessageEvent>() {//私聊监听
            @Override
            public void onMessage(PrivateMessageEvent privateMessage) {
                System.out.println(privateMessage);
            }
        });//快速监听

        dispatchers.start(10);//线程组处理任务

    }
}

Client

OneBot-Client 以 OneBot-v11 标准协议进行开发,兼容所有支持正向WebSocket的OneBot协议客户端

项目地址 平台 核心作者 备注
koishijs/koishi koishi shigma
onebot-walle/walle-q abrahum
Yiwen-Chan/OneBot-YaYa 先驱 kanri
richardchien/coolq-http-api CKYU richardchien 可在 Mirai 平台使用 mirai-native 加载
Mrs4s/go-cqhttp MiraiGo Mrs4s
yyuueexxiinngg/OneBot-Mirai Mirai yyuueexxiinngg
takayama-lily/onebot OICQ takayama

Credits

License

This product is licensed under the GNU General Public License version 3. The license is as published by the Free Software Foundation published at https://www.gnu.org/licenses/gpl-3.0.html.

Alternatively, this product is licensed under the GNU Lesser General Public License version 3 for non-commercial use. The license is as published by the Free Software Foundation published at https://www.gnu.org/licenses/lgpl-3.0.html.

Feel free to contact us if you have any questions about licensing or want to use the library in a commercial closed source product.

Thanks

Thanks JetBrains Provide Free License Support OpenSource Project

Stargazers over time

Stargazers over time

onebot-client's People

Contributors

cnlimiter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

xia-mc a0000xz

onebot-client's Issues

一些关于该项目的提议

  1. 项目名应改为 onebot-client-java
  2. 此外,其实java不适合做client,只适合做server,所以我建议是重点还是开发反向websocket。
  3. 演示代码有歧义,不应该起server 变量名,而是 client 比较合适。

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.