This repository has been archived by the owner on Jul 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit c114206.
- Loading branch information
Showing
31 changed files
with
1,026 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
plugins { | ||
id 'java' | ||
id 'com.github.johnrengelman.shadow' version '7.1.2' | ||
} | ||
|
||
build{ | ||
dependsOn { | ||
shadowJar | ||
} | ||
} | ||
|
||
jar { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
tasks.withType(JavaExec).configureEach { | ||
systemProperty 'file.encoding', 'UTF-8' | ||
} | ||
|
||
tasks.withType(JavaCompile).configureEach { | ||
options.encoding = 'UTF-8' | ||
} | ||
|
||
group = 'catx.feitu' | ||
version = '1.0.0213' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
// Discord API | ||
implementation 'org.javacord:javacord:3.8.0' | ||
|
||
// Slack API | ||
implementation "com.slack.api:bolt-socket-mode:1.38.1" | ||
implementation "com.slack.api:bolt-servlet:1.38.1" | ||
implementation "com.slack.api:bolt-jetty:1.38.1" | ||
implementation "org.slf4j:slf4j-simple:1.7.36" | ||
} |
23 changes: 23 additions & 0 deletions
23
CozeProxy/src/main/java/catx.feitu.CozeProxy/ConversationManage/ConversationData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package catx.feitu.CozeProxy.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; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
CozeProxy/src/main/java/catx.feitu.CozeProxy/ConversationManage/ConversationHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package catx.feitu.CozeProxy.ConversationManage; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.TypeReference; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
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); | ||
} | ||
public static List<String> conversationGetIdAsList (ConversationData conversation) { | ||
List<String> idList = Collections.synchronizedList(new ArrayList<>()); | ||
idList.addAll(conversation.getMap().values()); | ||
return idList; | ||
} | ||
public static List<String> conversationGetNameAsList (ConversationData conversation) { | ||
ConcurrentHashMap<String, String> map = conversation.getMap(); | ||
return new ArrayList<>(map.keySet()); | ||
} | ||
} |
Oops, something went wrong.