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

Commit

Permalink
Revert "Revert "[#] 重构 未完成 10%""
Browse files Browse the repository at this point in the history
This reverts commit c114206.
  • Loading branch information
NekoCurit committed Feb 17, 2024
1 parent c114206 commit 0355452
Show file tree
Hide file tree
Showing 31 changed files with 1,026 additions and 0 deletions.
41 changes: 41 additions & 0 deletions CozeProxy/build.gradle
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"
}
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;
}
}
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());
}
}
Loading

0 comments on commit 0355452

Please sign in to comment.