QQ官方机器人 Java/JVM/kotlin SDK QQ bot sdk qq机器人sdk
非官方 可用于 Java 8+
Java SDK主要基于基础 API (opens new window)封装,提供给用户一种简单、高效的使用方式。
使用前提
- 到https://q.qq.com/ 申请机器人 获得Bot 开发者ID(appid) 和 机器人令牌(token)
使用示例
启动方式 - Starter starter=new Starter("appid","token");
- starter.getConfig().setCode(Intents.PRIVATE_INTENTS.getCode());
- starter.run();
复制代码 V1.5.0-Beta7+ 注册监听器主机方式 [荐]- starter.registerListenerHost(new ListenerHost(){
- @EventReceiver
- public void onEvent(MessageEvent event){
- event.send("测试通过");
- }
- });
复制代码 V1.4.6
事件订阅 默认的事件订阅 不会接收消息事件
需要确定自己的机器人是公域还是私域
来确定 需要 设置订阅 的 事件类型 - //单事件订阅方式
- starter.getConfig().setCode(Intents.GUILD_MESSAGES.getCode());
- //多事件订阅方式
- starter.getConfig().setCode(Intents.START.and(Intents.GUILD_MESSAGES,Intents.DIRECT_MESSAGE));
- // 公域机器人订阅推荐
- starter.getConfig().setCode(Intents.PUBLIC_INTENTS.getCode());
- // 私域机器人订阅推荐
- starter.getConfig().setCode(Intents.PRIVATE_INTENTS.getCode());
复制代码 导入指引- import io.github.kloping.qqbot.Starter;
- import io.github.kloping.qqbot.api.Intents;
- import io.github.kloping.qqbot.api.message.MessageChannelReceiveEvent;
- import io.github.kloping.qqbot.api.message.MessageDirectReceiveEvent;
- import io.github.kloping.qqbot.impl.ListenerHost;
复制代码

链接: https://pan.baidu.com/s/1Vsr1fvDa8SXW2ARHkOBr7g
提取码下载:
|