Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
[#]整理代码 -> 重新写整个API
Browse files Browse the repository at this point in the history
仍不可构建,等待其它也重写完成
  • Loading branch information
NekoCurit committed Feb 3, 2024
1 parent e8c6954 commit fbeef72
Show file tree
Hide file tree
Showing 15 changed files with 211 additions and 376 deletions.
33 changes: 0 additions & 33 deletions src/main/java/catx/feitu/coze_discord_bridge/Discord/Discord.java

This file was deleted.

This file was deleted.

23 changes: 23 additions & 0 deletions src/main/java/catx/feitu/coze_discord_bridge/GPTManage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package catx.feitu.coze_discord_bridge;

import catx.feitu.coze_discord_bridge.api.CozeGPT;
import catx.feitu.coze_discord_bridge.api.CozeGPTConfig;

import java.util.concurrent.ConcurrentHashMap;

public class GPTManage {
private final ConcurrentHashMap<Object, CozeGPT> ResponseMap = new ConcurrentHashMap<>();
public void newGPT(String botID, CozeGPTConfig config) throws Exception {
ResponseMap.put(botID, new CozeGPT(config, true));
}
public CozeGPT getGPT(String botID) {
if (!ResponseMap.containsKey(botID)) {
throw new NullPointerException();
}
return ResponseMap.get(botID);
}
public void deleteGPT(String botID) {
ResponseMap.remove(botID);
}

}
154 changes: 0 additions & 154 deletions src/main/java/catx/feitu/coze_discord_bridge/Misc/CacheManager.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package catx.feitu.coze_discord_bridge.api.ConversationManage;

import java.util.concurrent.ConcurrentHashMap;

public class ConversationData {
public ConcurrentHashMap<String, String> conversations = new ConcurrentHashMap<>();
public ConversationData() { }
public ConversationData(ConcurrentHashMap<String, String> conversations) {
this.conversations = conversations;
}
public void put(String name,String conversationID) {
conversations.put(name, conversationID);
}

public void remove(String name) {
conversations.remove(name);
}
public String get(String name) {
return conversations.getOrDefault(name, name); // 索引为空那么传入的可能是频道ID 直接返回
}
public ConcurrentHashMap<String, String> getMap() {
return conversations;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package catx.feitu.coze_discord_bridge.api.ConversationManage;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;

import java.util.concurrent.ConcurrentHashMap;

public class ConversationHelper {
public static String Conversation2JsonString (ConversationData conversation) {
return JSON.toJSONString(conversation.getMap());
}
public static ConversationData JsonString2Conversation (String jsonString) {
TypeReference<ConcurrentHashMap<String, String>> typeRef = new TypeReference<ConcurrentHashMap<String, String>>() {};
ConcurrentHashMap<String, String> conversation = JSON.parseObject(jsonString, typeRef);
return new ConversationData(conversation);
}
}
Loading

0 comments on commit fbeef72

Please sign in to comment.