# qqpd-bot-java
**Repository Path**: helloSonyer/qqpd-bot-java
## Basic Information
- **Project Name**: qqpd-bot-java
- **Description**: QQ频道机器人 Java SDK 非官方
- **Primary Language**: Java
- **License**: AGPL-3.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1
- **Created**: 2024-08-29
- **Last Updated**: 2024-08-29
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README

## QQ机器人 Java/JVM/kotlin SDK
> 非官方 可用于 Java 8+
Java SDK主要基于[基础 API (opens new window)](https://bot.q.qq.com/wiki/develop/api/)封装,提供给用户一种简单、高效的使用方式。
Maven
```xml
io.github.kloping
bot-qqpd-java
1.5.1-R4
```
### 使用前提
1. 到https://q.qq.com/ 申请机器人 获得Bot 开发者ID(appid) 和 机器人令牌(token)
~~2. 发布审核 发布后为公域~~
### [开发文档](./docs) / [q群使用说明](./docs/v2.md)
### 使用示例
启动方式
```java
Starter starter=new Starter("appid","token");
starter.getConfig().setCode(Intents.PRIVATE_INTENTS.getCode());
starter.run();
```
> #### V1.5.0-Beta7+ 注册监听器主机方式 [荐]
```java
starter.registerListenerHost(new ListenerHost(){
@EventReceiver
public void onEvent(MessageEvent event){
event.send("测试通过");
}
});
```
> #### V1.4.6
> 事件订阅 默认的事件订阅 不会接收消息事件
> 需要确定自己的机器人是公域还是私域
> 来确定 需要 **[设置订阅](src/test/java/test_Intents.java)** 的 **[事件类型](src/main/java/io/github/kloping/qqbot/api/Intents.java)**
```java
//单事件订阅方式
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());
```
#### 导入指引
```java
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](./src/test/java)