Skip to content

Commit 8209e13

Browse files
Merge pull request #83 from ashinnotfound/feat/dall-3
Feat/dall-3 & TTS
2 parents 453fc68 + 6aa8874 commit 8209e13

File tree

17 files changed

+369
-285
lines changed

17 files changed

+369
-285
lines changed

README.md

Lines changed: 135 additions & 79 deletions
Large diffs are not rendered by default.

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>com.ashin</groupId>
1212
<artifactId>ChatGPT-YourChatRobot</artifactId>
13-
<version>3.8</version>
13+
<version>3.9</version>
1414
<name>myGPT</name>
1515
<description>快来把你的qq或微信变为chatgpt</description>
1616
<properties>
@@ -50,7 +50,7 @@
5050
<dependency>
5151
<groupId>com.theokanning.openai-gpt3-java</groupId>
5252
<artifactId>service</artifactId>
53-
<version>0.16.1</version>
53+
<version>0.18.2</version>
5454
</dependency>
5555
<dependency>
5656
<groupId>com.knuddels</groupId>

src/main/java/com/ashin/client/QqBotClient.java renamed to src/main/java/com/ashin/client/BotClient.java

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
package com.ashin.client;
22

3+
import cn.zhouyafeng.itchat4j.Wechat;
4+
import com.ashin.config.KeywordConfig;
35
import com.ashin.config.QqConfig;
6+
import com.ashin.config.WechatConfig;
47
import com.ashin.handler.QqMessageHandler;
8+
import com.ashin.handler.WechatMessageHandler;
9+
import com.ashin.service.InteractService;
10+
import com.ashin.util.BotUtil;
511
import lombok.Getter;
612
import lombok.extern.slf4j.Slf4j;
713
import net.mamoe.mirai.BotFactory;
@@ -14,19 +20,30 @@
1420

1521
@Component
1622
@Slf4j
17-
public class QqBotClient {
18-
19-
@Resource
20-
private QqMessageHandler qqMessageHandler;
23+
public class BotClient {
2124
@Resource
2225
private QqConfig qqConfig;
23-
24-
// qq机器人实例
2526
@Getter
2627
private net.mamoe.mirai.Bot qqBot;
28+
@Resource
29+
private WechatConfig wechatConfig;
30+
@Getter
31+
private Wechat wechatBot;
32+
@Resource
33+
private InteractService interactService;
34+
@Resource
35+
private KeywordConfig keywordConfig;
36+
@Resource
37+
private BotUtil botUtil;
2738

2839
@PostConstruct
2940
public void init() {
41+
//微信
42+
if (wechatConfig.getEnable()){
43+
log.info("正在登录微信,请按提示操作:");
44+
wechatBot = new Wechat(new WechatMessageHandler(interactService, keywordConfig, botUtil), wechatConfig.getQrPath());
45+
wechatBot.start();
46+
}
3047
if (qqConfig.getEnable()) {
3148
//登陆协议有ANDROID_PHONE, ANDROID_PAD, ANDROID_WATCH, IPAD, MACOS
3249
//若登陆失败可尝试更换协议
@@ -39,7 +56,7 @@ public void init() {
3956
qqBot.login();
4057
log.info("成功登录账号为 {} 的qq, 登陆协议为 {}", qqConfig.getAccount(), miraiProtocol);
4158
//订阅监听事件
42-
qqBot.getEventChannel().registerListenerHost(qqMessageHandler);
59+
qqBot.getEventChannel().registerListenerHost(new QqMessageHandler(interactService, qqConfig, keywordConfig, botUtil));
4360
} catch (Exception e) {
4461
log.error("登陆失败, qq账号为 {}, 登陆协议为 {}, 可尝试更换登陆协议, 具体原因: {}", qqConfig.getAccount(), miraiProtocol, e.getMessage());
4562
}

src/main/java/com/ashin/client/WechatBotClient.java

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

src/main/java/com/ashin/config/GptConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ public class GptConfig {
2222
private List<String> basicPrompt;
2323
private List<String> apiKey;
2424
private Long ofSeconds;
25+
private String imageQuality;
26+
private String imageStyle;
27+
private String audioModel;
28+
private String audioVoice;
29+
private Double audioSpeed;
2530
}

src/main/java/com/ashin/config/KeywordConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
@ConfigurationProperties("keyword")
1616
public class KeywordConfig {
1717
private String reset;
18-
private String draw;
18+
private String image;
19+
private String audio;
1920
}

src/main/java/com/ashin/config/QqConfig.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ public class QqConfig {
1818
private Long account;
1919
private Boolean acceptNewFriend;
2020
private Boolean acceptNewGroup;
21-
private Boolean returnDrawByURL;
2221
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.ashin.constant;
2+
3+
public enum ChatType {
4+
TEXT,
5+
IMAGE,
6+
AUDIO,
7+
}

src/main/java/com/ashin/entity/bo/ChatBO.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.ashin.entity.bo;
22

3+
import com.ashin.constant.ChatType;
34
import lombok.Data;
45

56
/**
@@ -21,5 +22,5 @@ public class ChatBO {
2122
/**
2223
* 是否ai画图功能
2324
*/
24-
private boolean isAiDraw;
25+
private ChatType chatType;
2526
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.ashin.entity.dto;
2+
3+
import lombok.Data;
4+
5+
import java.io.InputStream;
6+
7+
@Data
8+
public class ChatResultDTO {
9+
String StringResult;
10+
InputStream inputStreamResult;
11+
byte[] bytesResult;
12+
}

0 commit comments

Comments
 (0)