Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.

Commit f3e6262

Browse files
committed
1.0.1 Released
完全重构, 从qq-official-bot-sdk更名为qqbot 分以下模块 qqbot-common: 公共文件 实体类等 qqbot-api: API接口 可单独使用 qqbot-websocket: Ws连接实现 本次提交commit如下: qqbot-sdk: api: 添加私域接口 websocket: EventHandler添加onError方法
1 parent f6749ee commit f3e6262

File tree

26 files changed

+273
-105
lines changed

26 files changed

+273
-105
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea
22
*.iml
3-
target
3+
target
4+
pom.xml.versionsBackup

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,45 @@ class IEventHandler extends EventHandler {
110110
}
111111
}
112112
```
113+
114+
## 单独使用API
115+
116+
```xml
117+
118+
<dependency>
119+
<groupId>me.zhenxin</groupId>
120+
<artifactId>qqbot-api</artifactId>
121+
<version>${version}</version>
122+
</dependency>
123+
```
124+
125+
```java
126+
127+
@Slf4j
128+
class Example {
129+
public static void main(String[] args) {
130+
AccessInfo accessInfo = new AccessInfo();
131+
accessInfo.setBotAppId(0); // 管理端的BotAppId
132+
accessInfo.setBotToken(""); // 管理端的BotToken
133+
// 使用沙盒模式
134+
accessInfo.useSandBoxMode();
135+
// 创建实例
136+
ApiManager api = new ApiManager(accessInfo);
137+
// 调用
138+
List<Guild> guilds = api.getUserApi().getMeGuilds();
139+
140+
log.info("{}", guilds);
141+
}
142+
}
143+
```
144+
145+
## 自定义日志级别
146+
147+
添加环境变量 `LogLevel` 设置日志级别
148+
149+
| 等级 | 描述 |
150+
|-------|------------------|
151+
| INFO | 信息 对应log.info() |
152+
| DEBUG | 调试 对应log.debug() |
153+
| WARN | 警告 对应log.warn() |
154+
| ERROR | 错误 对应log.error() |

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<groupId>me.zhenxin</groupId>
1111
<artifactId>qqbot-parent</artifactId>
1212
<packaging>pom</packaging>
13-
<version>1.0.0</version>
13+
<version>1.0.1</version>
1414
<modules>
1515
<module>qqbot-common</module>
1616
<module>qqbot-api</module>

qqbot-api/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>qqbot-parent</artifactId>
77
<groupId>me.zhenxin</groupId>
8-
<version>1.0.0</version>
8+
<version>1.0.1</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>me.zhenxin</groupId>
2222
<artifactId>qqbot-common</artifactId>
23-
<version>1.0.0</version>
23+
<version>1.0.1</version>
2424
</dependency>
2525
<!-- hutool -->
2626
<dependency>

qqbot-api/src/main/java/me/zhenxin/qqbot/api/ApiManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.zhenxin.qqbot.api;
22

3+
import me.zhenxin.qqbot.api.impl.*;
34
import me.zhenxin.qqbot.entity.AccessInfo;
45

56
/**
@@ -17,8 +18,8 @@ public class ApiManager {
1718
*
1819
* @param accessInfo 访问信息
1920
*/
20-
public ApiManager(AccessInfo accessInfo, Boolean useSandBoxMode) {
21-
this.useSandBoxMode = useSandBoxMode;
21+
public ApiManager(AccessInfo accessInfo) {
22+
this.useSandBoxMode = accessInfo.getUseSandBoxMode();
2223
Integer botAppId = accessInfo.getBotAppId();
2324
String botToken = accessInfo.getBotToken();
2425
this.token = "Bot " + botAppId + "." + botToken;

qqbot-api/src/main/java/me/zhenxin/qqbot/api/BaseApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected <T> T put(String path, Map<String, Object> data, Class<T> tClass) thro
7171
return result(call, tClass);
7272
}
7373

74-
protected <T> T delete(String path, Map<String, Object> data, Class<T> tClass) throws ApiException {
74+
protected void delete(String path, Map<String, Object> data) throws ApiException {
7575
log.debug("DELETE Data: {}", JSON.toJSONString(data));
7676
RequestBody body = RequestBody.create(JSON.toJSONString(data), mediaType);
7777
Request request =
@@ -81,7 +81,7 @@ protected <T> T delete(String path, Map<String, Object> data, Class<T> tClass) t
8181
.delete(body)
8282
.build();
8383
Call call = client.newCall(request);
84-
return result(call, tClass);
84+
result(call, null);
8585
}
8686

8787
protected <T> T patch(String path, Map<String, Object> data, Class<T> tClass) throws ApiException {

qqbot-api/src/main/java/me/zhenxin/qqbot/api/ChannelApi.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

qqbot-api/src/main/java/me/zhenxin/qqbot/api/GuildApi.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

qqbot-api/src/main/java/me/zhenxin/qqbot/api/AnnouncesApi.java renamed to qqbot-api/src/main/java/me/zhenxin/qqbot/api/impl/AnnouncesApi.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
package me.zhenxin.qqbot.api;
1+
package me.zhenxin.qqbot.api.impl;
22

3+
import me.zhenxin.qqbot.api.BaseApi;
34
import me.zhenxin.qqbot.entity.Announces;
45
import me.zhenxin.qqbot.exception.ApiException;
56

@@ -39,7 +40,7 @@ public Announces createGuildAnnounces(String guildId, String channelId, String m
3940
* @param messageId 消息ID
4041
*/
4142
public void deleteGuildAnnounces(String guildId, String messageId) throws ApiException {
42-
delete("/guilds/" + guildId + "/announces/" + messageId, null, null);
43+
delete("/guilds/" + guildId + "/announces/" + messageId, null);
4344
}
4445

4546
/**
@@ -61,6 +62,6 @@ public Announces createAnnounces(String channelId, String messageId) throws ApiE
6162
* @param messageId 消息ID
6263
*/
6364
public void deleteAnnounces(String channelId, String messageId) throws ApiException {
64-
delete("/channels/" + channelId + "/announces/" + messageId, null, null);
65+
delete("/channels/" + channelId + "/announces/" + messageId, null);
6566
}
6667
}

qqbot-api/src/main/java/me/zhenxin/qqbot/api/AudioApi.java renamed to qqbot-api/src/main/java/me/zhenxin/qqbot/api/impl/AudioApi.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
package me.zhenxin.qqbot.api;
1+
package me.zhenxin.qqbot.api.impl;
22

33
import cn.hutool.core.bean.BeanUtil;
4+
import me.zhenxin.qqbot.api.BaseApi;
45
import me.zhenxin.qqbot.entity.AudioControl;
56

67
/**

0 commit comments

Comments
 (0)