改成onebot-11通用接口 #9

Merged
yutou merged 10 commits from dev_HTTP服务化 into master 2024-05-10 13:09:42 +08:00
3 changed files with 23 additions and 1 deletions
Showing only changes of commit 400f2df6ab - Show all commits

View File

@ -10,7 +10,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class QQBotApplication { public class QQBotApplication {
public static final String version = "QQBot v.1.7"; public static final String version = "QQBot v.1.7.1";
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("version = " + version); System.out.println("version = " + version);

View File

@ -8,10 +8,14 @@ import com.yutou.qqbot.data.baidu.ResponseMessage;
import com.yutou.qqbot.models.Model; import com.yutou.qqbot.models.Model;
import com.yutou.qqbot.utlis.BaiduGPTManager; import com.yutou.qqbot.utlis.BaiduGPTManager;
import com.yutou.napcat.event.MessageEvent; import com.yutou.napcat.event.MessageEvent;
import com.yutou.qqbot.utlis.ConfigTools;
import com.yutou.qqbot.utlis.StringUtils;
@UseModel @UseModel
public class BaiduGPT extends Model { public class BaiduGPT extends Model {
private static String version = null;
@Override @Override
public boolean isUserPublic() { public boolean isUserPublic() {
return true; return true;
@ -33,6 +37,18 @@ public class BaiduGPT extends Model {
@Override @Override
public void onMessage(Long qq, MessageEvent event, boolean isGroup) { public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
super.onMessage(qq, event, isGroup); super.onMessage(qq, event, isGroup);
if (version == null) {
version = ConfigTools.load(ConfigTools.CONFIG, "baidu.gpt.version", String.class);
if (StringUtils.isEmpty(version)) {
version = "3.5";
BaiduGPTManager.getManager().setModelFor35();
}
}
if ("3.5".equals(version)) {
BaiduGPTManager.getManager().setModelFor35();
} else if ("4.0".equals(version)) {
BaiduGPTManager.getManager().setModelFor40();
}
if (event.getTextMessage().equals(QQGroupCommands.GPT_CLEAR)) { if (event.getTextMessage().equals(QQGroupCommands.GPT_CLEAR)) {
BaiduGPTManager.getManager().clear(); BaiduGPTManager.getManager().clear();
QQBotManager.getInstance().sendMessage(event.isUser(), qq, new Text("已经失忆捏")); QQBotManager.getInstance().sendMessage(event.isUser(), qq, new Text("已经失忆捏"));
@ -61,4 +77,8 @@ public class BaiduGPT extends Model {
QQBotManager.getInstance().sendMessage(event.isUser(), qq, new Text(sb)); QQBotManager.getInstance().sendMessage(event.isUser(), qq, new Text(sb));
} }
} }
public static void main(String[] args) {
System.out.println(ConfigTools.load(ConfigTools.CONFIG,"baidu.gpt.version"));
}
} }

View File

@ -40,10 +40,12 @@ public class BaiduGPTManager {
public void setModelFor40() { public void setModelFor40() {
url = url_4_0; url = url_4_0;
ConfigTools.save(ConfigTools.CONFIG,"baidu.gpt.version","4.0");
} }
public void setModelFor35() { public void setModelFor35() {
url = url_3_5; url = url_3_5;
ConfigTools.save(ConfigTools.CONFIG,"baidu.gpt.version","3.5");
} }
public void clear() { public void clear() {