改成onebot-11通用接口 #9
@ -7,7 +7,7 @@ import com.yutou.qqbot.utlis.ConfigTools;
|
||||
public class NapCatApi extends BaseApi {
|
||||
private static final String URL;
|
||||
static {
|
||||
URL= ConfigTools.load(ConfigTools.CONFIG,"napcat.url",String.class);
|
||||
URL= ConfigTools.load(ConfigTools.CONFIG,ConfigTools.NAPCAT_URL,String.class);
|
||||
}
|
||||
|
||||
public static void setLog(boolean log){
|
||||
|
@ -10,7 +10,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class QQBotApplication {
|
||||
public static final String version = "QQBot v.1.7.2";
|
||||
public static final String version = "QQBot v.1.7.3";
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("version = " + version);
|
||||
@ -18,7 +18,7 @@ public class QQBotApplication {
|
||||
NapCatApi.setLog(true);
|
||||
RedisTools.initRedisPoolSub();
|
||||
QQBotManager.getInstance();
|
||||
val log = ConfigTools.load(ConfigTools.CONFIG, "qq.log", Boolean.class);
|
||||
val log = ConfigTools.load(ConfigTools.CONFIG, ConfigTools.QQ_LOG, Boolean.class);
|
||||
NapCatApi.setLog(log);
|
||||
//1
|
||||
}
|
||||
|
@ -120,6 +120,9 @@ public class QQBotManager {
|
||||
|
||||
public SendMessageResponse sendMessage(boolean isUser, Long qq, List<BaseHandle<?>> items) {
|
||||
try {
|
||||
if(!ConfigTools.load(ConfigTools.CONFIG,ConfigTools.QQ, Boolean.class)){
|
||||
return null;
|
||||
}
|
||||
MessageHandleBuild handleBuild = MessageHandleBuild
|
||||
.create()
|
||||
.setGroup(!isUser)
|
||||
|
@ -333,7 +333,7 @@ public class BiliBiliUtils {
|
||||
public void download_ffmpeg(final List<String> url, final String saveName) {
|
||||
new Thread(() -> {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(ConfigTools.load(ConfigTools.CONFIG, "ffmpeg", String.class)).append(" ");
|
||||
builder.append(ConfigTools.load(ConfigTools.CONFIG, ConfigTools.FFMPEG, String.class)).append(" ");
|
||||
/* builder.append("-user_agent").append(" ");
|
||||
builder.append("\"").append("User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36 Referer:https://live.bilibili.com").append("\"").append(" ");
|
||||
builder.append("-cookies").append(" ");
|
||||
|
@ -10,12 +10,14 @@ import com.yutou.qqbot.utlis.BaiduGPTManager;
|
||||
import com.yutou.napcat.event.MessageEvent;
|
||||
import com.yutou.qqbot.utlis.ConfigTools;
|
||||
import com.yutou.qqbot.utlis.StringUtils;
|
||||
import lombok.val;
|
||||
import org.apache.catalina.valves.JsonErrorReportValve;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@UseModel
|
||||
public class BaiduGPT extends Model {
|
||||
|
||||
private static String version = null;
|
||||
|
||||
@Override
|
||||
public boolean isUserPublic() {
|
||||
return true;
|
||||
@ -37,18 +39,17 @@ public class BaiduGPT extends Model {
|
||||
@Override
|
||||
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
|
||||
super.onMessage(qq, event, isGroup);
|
||||
if (version == null) {
|
||||
version = ConfigTools.load(ConfigTools.CONFIG, "baidu.gpt.version", String.class);
|
||||
String version = ConfigTools.load(ConfigTools.CONFIG, ConfigTools.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();
|
||||
}
|
||||
System.out.println("version = " + version);
|
||||
if (event.getTextMessage().equals(QQGroupCommands.GPT_CLEAR)) {
|
||||
BaiduGPTManager.getManager().clear();
|
||||
QQBotManager.getInstance().sendMessage(event.isUser(), qq, new Text("已经失忆捏"));
|
||||
@ -79,6 +80,16 @@ public class BaiduGPT extends Model {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(ConfigTools.load(ConfigTools.CONFIG,"baidu.gpt.version"));
|
||||
System.out.println(ConfigTools.load(ConfigTools.CONFIG, ConfigTools.BAIDU_GPT_VERSION));
|
||||
val messageEvent = new MessageEvent();
|
||||
messageEvent.setMessage(new ArrayList<>());
|
||||
messageEvent.setRawMessage("");
|
||||
new BaiduGPT().onMessage(123456789L, messageEvent, false);
|
||||
BaiduGPTManager.getManager().clear();
|
||||
BaiduGPTManager.getManager().setModelFor40();
|
||||
new BaiduGPT().onMessage(123456789L, messageEvent, false);
|
||||
/* BaiduGPTManager.getManager().clear();
|
||||
BaiduGPTManager.getManager().setModelFor35();
|
||||
new BaiduGPT().onMessage(123456789L, messageEvent, false);*/
|
||||
}
|
||||
}
|
||||
|
@ -122,6 +122,6 @@ public abstract class Model implements ModelInterface {
|
||||
}
|
||||
|
||||
public boolean isAt() {
|
||||
return msg.contains("@" + ConfigTools.load(ConfigTools.CONFIG, "qq_number", String.class));
|
||||
return msg.contains("@" + ConfigTools.load(ConfigTools.CONFIG, ConfigTools.QQ_NUMBER, String.class));
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ public class AppTools {
|
||||
Log.i("title=" + title + " msg=" + msg);
|
||||
HttpTools.post("https://sctapi.ftqq.com/SCT2619Tpqu93OYtQCrK4LOZYEfr2irm.send",
|
||||
("title="+ URLEncoder.encode(title, "UTF-8") + "&desp=" + URLEncoder.encode(msg, "UTF-8")).getBytes(StandardCharsets.UTF_8));
|
||||
if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("nas")) {
|
||||
if (ConfigTools.load(ConfigTools.CONFIG, ConfigTools.MODEL).equals("nas")) {
|
||||
String img = null;
|
||||
msg = msg.replace("<br/>", "\n");
|
||||
if (msg.contains("![logo]")) {
|
||||
|
@ -17,9 +17,9 @@ public class BaiduGPTManager {
|
||||
//4.0
|
||||
private static final String url_4_0 = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro";
|
||||
private static String url = url_3_5;
|
||||
private static final String AppID = ConfigTools.load(ConfigTools.CONFIG,"baidu.gpt.appid", String.class);
|
||||
private static final String ApiKey =ConfigTools.load(ConfigTools.CONFIG,"baidu.gpt.apikey", String.class);
|
||||
private static final String SecretKey =ConfigTools.load(ConfigTools.CONFIG,"baidu.gpt.SecretKey", String.class);
|
||||
private static final String AppID = ConfigTools.load(ConfigTools.CONFIG,ConfigTools.BAIDU_GPT_APPID, String.class);
|
||||
private static final String ApiKey =ConfigTools.load(ConfigTools.CONFIG,ConfigTools.BAIDU_GPT_API_KEY, String.class);
|
||||
private static final String SecretKey =ConfigTools.load(ConfigTools.CONFIG,ConfigTools.BAIDU_GPT_SECRET_KEY, String.class);
|
||||
private final Map<String, List<Message>> msgMap;
|
||||
|
||||
private BaiduGPTManager() {
|
||||
@ -40,12 +40,12 @@ public class BaiduGPTManager {
|
||||
|
||||
public void setModelFor40() {
|
||||
url = url_4_0;
|
||||
ConfigTools.save(ConfigTools.CONFIG,"baidu.gpt.version","4.0");
|
||||
ConfigTools.save(ConfigTools.CONFIG,ConfigTools.BAIDU_GPT_VERSION,"4.0");
|
||||
}
|
||||
|
||||
public void setModelFor35() {
|
||||
url = url_3_5;
|
||||
ConfigTools.save(ConfigTools.CONFIG,"baidu.gpt.version","3.5");
|
||||
ConfigTools.save(ConfigTools.CONFIG,ConfigTools.BAIDU_GPT_VERSION,"3.5");
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
|
@ -13,8 +13,25 @@ public class ConfigTools {
|
||||
public static final String DATA = "data.json";
|
||||
public static final String SQLITE = "sqlite.json";
|
||||
public static final String BiliBili = "bilibili.cookie";
|
||||
public static final String QQ = "qq_bot";
|
||||
public static final String QQ_NUMBER = "qq_number";
|
||||
public static final String QQ_PASSWORD = "qq_password";
|
||||
public static final String MODEL = "model";
|
||||
public static final String OS = "os";
|
||||
public static final String MUSIC_SCAN = "musicScan";
|
||||
public static final String SERVICE_LOG = "service.log";
|
||||
public static final String QQ_LOG = "qq.log";
|
||||
public static final String CHROME = "chrome";
|
||||
public static final String FIREFOX = "firefox";
|
||||
public static final String FFMPEG = "ffmpeg";
|
||||
public static final String SIGN_URL = "sign_url";
|
||||
public static final String NAPCAT_URL = "napcat.url";
|
||||
public static final String SERVER_URL = "server.url";
|
||||
public static final String BAIDU_GPT_VERSION = "baidu.gpt.version";
|
||||
public static final String BAIDU_GPT_APPID = "baidu.gpt.appid";
|
||||
public static final String BAIDU_GPT_API_KEY = "baidu.gpt.apikey";
|
||||
public static final String BAIDU_GPT_SECRET_KEY = "baidu.gpt.SecretKey";
|
||||
|
||||
private static final String SERVER_URL = load(CONFIG, "server.url", String.class);
|
||||
|
||||
static {
|
||||
try {
|
||||
@ -120,6 +137,6 @@ public class ConfigTools {
|
||||
}
|
||||
|
||||
public static String getServerUrl() {
|
||||
return SERVER_URL;
|
||||
return ConfigTools.load(CONFIG, SERVER_URL, String.class);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ public class Log {
|
||||
}
|
||||
|
||||
public static void i(Object log) {
|
||||
if (ConfigTools.load(ConfigTools.CONFIG, "service.log", boolean.class, false)) {
|
||||
if (ConfigTools.load(ConfigTools.CONFIG, ConfigTools.SERVICE_LOG, boolean.class, false)) {
|
||||
System.out.printf("[%s]%s%n",
|
||||
AppTools.getToDayNowTimeToString(),
|
||||
log
|
||||
|
@ -39,7 +39,7 @@ public class WebClient {
|
||||
private WebClient() {
|
||||
//System.setProperty("webdriver.http.factory", "jdk-http-client");
|
||||
System.setProperty("webdriver.chrome.driver",
|
||||
ConfigTools.load(ConfigTools.CONFIG, "chrome", String.class));
|
||||
ConfigTools.load(ConfigTools.CONFIG, ConfigTools.CHROME, String.class));
|
||||
// System.setProperty("webdriver.chrome.whitelistedIps", "");
|
||||
// java.util.logging.Logger.getLogger("org.openqa.selenium").setLevel(Level.OFF);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user