非官方 可用于 Java 8+
Java SDK主要基于基础 API (opens new window)封装,提供给用户一种简单、高效的使用方式。
- 支持QQ官方频道与Q群消息收发(私域/公域兼容)
- 开箱即用的消息类型(文本/图片/Markdown/按钮交互)
- 灵活的事件监听机制(
@EventReceiver
注解驱动) - 多环境支持(沙箱/正式环境一键切换)
- 完善的HTTP API封装(频道管理、禁言、消息审核等)
- 支持Java 8+及Kotlin协程环境
- 支持
websocket
与webhook
方式链接
Maven
<!-- https://repo1.maven.org/maven2/io/github/kloping/bot-qqpd-java/ -->
<dependency>
<groupId>io.github.kloping</groupId>
<artifactId>bot-qqpd-java</artifactId>
<version>1.5.2-R3</version>
</dependency>
Gradle
implementation 'io.github.kloping:bot-qqpd-java:1.5.2-R3'
- 到https://q.qq.com/ 申请机器人 获得Bot 开发者ID(appid) 和 机器人令牌(token)
2. 发布审核 发布后为公域
启动方式
Starter starter = new Starter("appid","token");
//如果使用q群 则 new Starter("appid", "token", "secret");
starter.getConfig().setCode(Intents.PRIVATE_INTENTS.getCode());
// webhook 链接方式
//starter.getConfig().setWebhookport(81);
starter.run();
starter.registerListenerHost(new ListenerHost(){
@EventReceiver
public void onEvent(MessageEvent event){
event.send("测试通过");
}
});
//单事件订阅方式
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;
更多使用方式参考查看 test