diff --git a/.gradle/7.4/checksums/checksums.lock b/.gradle/7.4/checksums/checksums.lock
index 567ce54c..d58984ec 100644
Binary files a/.gradle/7.4/checksums/checksums.lock and b/.gradle/7.4/checksums/checksums.lock differ
diff --git a/.gradle/7.4/checksums/md5-checksums.bin b/.gradle/7.4/checksums/md5-checksums.bin
index f51d8709..9d9a66cc 100644
Binary files a/.gradle/7.4/checksums/md5-checksums.bin and b/.gradle/7.4/checksums/md5-checksums.bin differ
diff --git a/.gradle/7.4/checksums/sha1-checksums.bin b/.gradle/7.4/checksums/sha1-checksums.bin
index 77d3611e..71dfbaeb 100644
Binary files a/.gradle/7.4/checksums/sha1-checksums.bin and b/.gradle/7.4/checksums/sha1-checksums.bin differ
diff --git a/.gradle/7.4/executionHistory/executionHistory.bin b/.gradle/7.4/executionHistory/executionHistory.bin
index 23b5b450..22d4fd53 100644
Binary files a/.gradle/7.4/executionHistory/executionHistory.bin and b/.gradle/7.4/executionHistory/executionHistory.bin differ
diff --git a/.gradle/7.4/executionHistory/executionHistory.lock b/.gradle/7.4/executionHistory/executionHistory.lock
index 444f3071..ee312e42 100644
Binary files a/.gradle/7.4/executionHistory/executionHistory.lock and b/.gradle/7.4/executionHistory/executionHistory.lock differ
diff --git a/.gradle/7.4/fileHashes/fileHashes.bin b/.gradle/7.4/fileHashes/fileHashes.bin
index 33d4b8a9..3ddac990 100644
Binary files a/.gradle/7.4/fileHashes/fileHashes.bin and b/.gradle/7.4/fileHashes/fileHashes.bin differ
diff --git a/.gradle/7.4/fileHashes/fileHashes.lock b/.gradle/7.4/fileHashes/fileHashes.lock
index c6816f51..9b06c0c7 100644
Binary files a/.gradle/7.4/fileHashes/fileHashes.lock and b/.gradle/7.4/fileHashes/fileHashes.lock differ
diff --git a/.gradle/7.4/fileHashes/resourceHashesCache.bin b/.gradle/7.4/fileHashes/resourceHashesCache.bin
index 07413389..083df46d 100644
Binary files a/.gradle/7.4/fileHashes/resourceHashesCache.bin and b/.gradle/7.4/fileHashes/resourceHashesCache.bin differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index b449ebdb..3af5ae9a 100644
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin
index 26e1b6cf..deb82052 100644
Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe
index 9cbe4986..4572580a 100644
Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index 4251b727..2b8a50fc 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 690a2823..3c64ba63 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,17 +4,12 @@
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
@@ -67,12 +62,25 @@
-
+
+
+
+
+
+
-
-
-
+
+
+
-
+
@@ -198,17 +206,17 @@
-
+
+
-
@@ -543,7 +551,35 @@
1672825015018
-
+
+ 1672892586123
+
+
+
+ 1672892586123
+
+
+ 1672892663788
+
+
+
+ 1672892663788
+
+
+ 1673008269839
+
+
+
+ 1673008269839
+
+
+ 1673092758302
+
+
+
+ 1673092758302
+
+
@@ -564,9 +600,6 @@
-
-
-
@@ -589,7 +622,10 @@
-
+
+
+
+
diff --git a/README.md b/README.md
index f964cf2e..2d1f7ef7 100644
--- a/README.md
+++ b/README.md
@@ -326,6 +326,45 @@ qwhitelist:
+#### extra-configs/trchat.yml
+
+
+点此展开/收起
+
+```yaml
+# 聊天转发
+chat-forward:
+ # 需要转发的频道
+ channel:
+ - Normal
+```
+
+
+
+#### extra-configs/command-alias.yml
+
+
+点此展开/收起
+
+```yaml
+# CatSero QQ CommandAlias Config
+# Generate by CatSero v@plugin.version@
+
+# 功能开关
+# true | false
+enable: false
+
+# 别名列表
+tps:
+ - ctps
+list:
+ - clist
+whitelist:
+ - cwl
+```
+
+
+
#### Bot & Group & QQOp配置指南
diff --git a/build.gradle.kts b/build.gradle.kts
index 59b077c1..02056c4c 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -7,7 +7,7 @@ plugins {
}
group = "moe.xmcn.catsero"
-version = "2.1-beta-2"
+version = "2.1"
repositories {
mavenCentral()
diff --git a/config.groovy b/config.groovy
index 47e8b437..9034e00d 100644
--- a/config.groovy
+++ b/config.groovy
@@ -1,7 +1,7 @@
environments {
prod {
plugin {
- version = "2.1-beta-2"
+ version = "2.1"
}
}
}
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 41dfb879..95db1416 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
+distributionUrl=https://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/src/main/java/moe/xmcn/catsero/Configuration.java b/src/main/java/moe/xmcn/catsero/Configuration.java
index a8dd5ddf..c08597f1 100644
--- a/src/main/java/moe/xmcn/catsero/Configuration.java
+++ b/src/main/java/moe/xmcn/catsero/Configuration.java
@@ -95,6 +95,9 @@ static void saveFiles() {
if (!new File(plugin.getDataFolder(), "extra-configs/trchat.yml").exists()) {
plugin.saveResource("extra-configs/trchat.yml", false);
}
+ if (!new File(plugin.getDataFolder(), "extra-configs/command-alias.yml").exists()) {
+ plugin.saveResource("extra-configs/command-alias.yml", false);
+ }
Logger.logLoader("Saved.");
Logger.logLoader("Saving default locale...");
@@ -608,6 +611,8 @@ class CFI {
static final FileConfiguration qqop_config = YamlConfiguration.loadConfiguration(mirai_qqop_file);
static final File ext_trchat_file = new File(plugin.getDataFolder(), "extra-configs/trchat.yml");
static final FileConfiguration ext_trchat_config = YamlConfiguration.loadConfiguration(ext_trchat_file);
+ static final File command_alias_file = new File(plugin.getDataFolder(), "extra-configs/command-alias.yml");
+ public static final FileConfiguration command_alias_config = YamlConfiguration.loadConfiguration(command_alias_file);
}
}
diff --git a/src/main/java/moe/xmcn/catsero/listeners/getonlinelist/OnGroupMessageRequestList.java b/src/main/java/moe/xmcn/catsero/listeners/getonlinelist/OnGroupMessageRequestList.java
index 7cecadea..3139fdc4 100644
--- a/src/main/java/moe/xmcn/catsero/listeners/getonlinelist/OnGroupMessageRequestList.java
+++ b/src/main/java/moe/xmcn/catsero/listeners/getonlinelist/OnGroupMessageRequestList.java
@@ -43,13 +43,12 @@ public class OnGroupMessageRequestList implements Listener {
@EventHandler
public void onGroupMessage(MiraiGroupMessageEvent e) {
try {
- String[] args = QPS.parse(e.getMessage());
+ String[] args = QPS.parse(e.getMessage(), "list");
if (args != null) {
// 条件
if (
Configuration.USES_CONFIG.GET_ONLINE_LIST.ENABLE
- && args[0].equalsIgnoreCase("list")
&& e.getBotID() == Configuration.Interface.getBotCode(Configuration.USES_CONFIG.GET_ONLINE_LIST.MIRAI.BOT)
&& e.getGroupID() == Configuration.Interface.getGroupCode(Configuration.USES_CONFIG.GET_ONLINE_LIST.MIRAI.GROUP)
) {
diff --git a/src/main/java/moe/xmcn/catsero/listeners/gettps/OnGroupMessageRequestTPS.java b/src/main/java/moe/xmcn/catsero/listeners/gettps/OnGroupMessageRequestTPS.java
index 426b851a..450687bf 100644
--- a/src/main/java/moe/xmcn/catsero/listeners/gettps/OnGroupMessageRequestTPS.java
+++ b/src/main/java/moe/xmcn/catsero/listeners/gettps/OnGroupMessageRequestTPS.java
@@ -38,23 +38,22 @@ public class OnGroupMessageRequestTPS implements Listener {
@EventHandler
public void onGroupMessageEvent(MiraiGroupMessageEvent e) {
- String[] args = QPS.parse(e.getMessage());
+ String[] args = QPS.parse(e.getMessage(), "tps");
if (args != null) {
// 条件
if (
Configuration.USES_CONFIG.GET_TPS.ENABLE
- && args[0].equalsIgnoreCase("tps")
&& e.getBotID() == Configuration.Interface.getBotCode(Configuration.USES_CONFIG.GET_ONLINE_LIST.MIRAI.BOT)
&& e.getGroupID() == Configuration.Interface.getGroupCode(Configuration.USES_CONFIG.GET_ONLINE_LIST.MIRAI.GROUP)
) {
- if (args.length == 2) {
+ if (args.length == 1) {
// 处理TPS
double tps = TPSCalculator.getTPS();
BigDecimal around_tps = BigDecimal.valueOf(tps).setScale(1, RoundingMode.HALF_UP);
- switch (args[1]) {
+ switch (args[0]) {
case "accurate":
// 精确
MessageSender.sendGroup("TPS: " + tps, Configuration.USES_CONFIG.GET_TPS.MIRAI.BOT, Configuration.USES_CONFIG.GET_TPS.MIRAI.GROUP);
diff --git a/src/main/java/moe/xmcn/catsero/utils/QPS.java b/src/main/java/moe/xmcn/catsero/utils/QPS.java
index 58311baa..e55641e1 100644
--- a/src/main/java/moe/xmcn/catsero/utils/QPS.java
+++ b/src/main/java/moe/xmcn/catsero/utils/QPS.java
@@ -24,15 +24,50 @@
package moe.xmcn.catsero.utils;
import moe.xmcn.catsero.Configuration;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
public interface QPS {
+ /**
+ * 解析命令
+ * @param message 接收消息原文
+ * @param command 命令名称
+ * @return 解析后的数组,如果解析失败则直接返回null
+ */
+ static String[] parse(@NotNull String message, @NotNull String command) {
+ /*
+ 思路:先检查默认的命令,如不成功则继续检查别名
+ 直接将命令去除,返回参数
+ */
+ String vcp = new ParseTool().vCheckP(message, command);
+ String ccp = new ParseTool().cCheckP(message, command);
+ String ecp = new ParseTool().eCheckP(message, command);
+
+ /*
+ System.out.println(vcp);
+ System.out.println(ccp);
+ System.out.println(ecp);
+
+ */
+
+ if (vcp != null)
+ return vcp.split(" ");
+ else if (ccp != null)
+ return ccp.split(" ");
+ else if (ecp != null)
+ return ecp.split(" ");
+ return null;
+ }
+
/**
* 解析QQ群命令
*
* @param message 消息
* @return 数组或null
*/
+ @Deprecated
static String[] parse(String message) {
String pmhv = getParser.checkViaCommandHeader(message);
String pmhc = getParser.checkCustomCommandHeader(message);
@@ -48,6 +83,68 @@ static String[] parse(String message) {
}
}
+ class ParseTool {
+
+ String ess = null;
+
+ private String vCheckP(@NotNull String message, @NotNull String command) {
+ //解析命令头(/,!)
+ if (message.startsWith("!catsero " + command)) {
+ return message.replaceFirst(
+ "!catsero " + command + " ",
+ ""
+ );
+ } else if (message.startsWith("/catsero " + command)) {
+ return message.replaceFirst(
+ "/catsero " + command + " ",
+ ""
+ );
+ }
+ return null;
+ }
+
+ private String cCheckP(@NotNull String message, @NotNull String command) {
+ if (message.startsWith("!" + Configuration.PLUGIN.COMMAND_PREFIX.PREFIX + " " + command)) {
+ // CH -> !
+ return message.replaceFirst(
+ "!" + Configuration.PLUGIN.COMMAND_PREFIX.PREFIX + command + " ",
+ ""
+ );
+ } else if (message.startsWith("/" + Configuration.PLUGIN.COMMAND_PREFIX.PREFIX + " " + command)) {
+ // CH -> /
+ return message.replaceFirst(
+ "/" + Configuration.PLUGIN.COMMAND_PREFIX.PREFIX + command + " ",
+ ""
+ );
+ }
+ return null;
+ }
+
+ private String eCheckP(@NotNull String message, @NotNull String command) {
+ if (Configuration.CFI.command_alias_config.getBoolean("enable")) {
+ List aliasList = Configuration.CFI.command_alias_config.getStringList(command);
+ aliasList.forEach(alias -> {
+ if (message.startsWith("!" + alias)) {
+ // CH -> !
+ ess = message.replaceFirst(
+ "!" + alias + " ",
+ ""
+ );
+ } else if (message.startsWith("/" + alias)) {
+ // CH -> /
+ ess = message.replaceFirst(
+ "/" + alias + " ",
+ ""
+ );
+ }
+ });
+ return ess;
+ }
+ return null;
+ }
+ }
+
+ @Deprecated
class getParser {
/**
diff --git a/src/main/kotlin/moe/xmcn/catsero/listeners/qwhitelist/WhiteListEditor.kt b/src/main/kotlin/moe/xmcn/catsero/listeners/qwhitelist/WhiteListEditor.kt
index bf77bce2..f8d722c1 100644
--- a/src/main/kotlin/moe/xmcn/catsero/listeners/qwhitelist/WhiteListEditor.kt
+++ b/src/main/kotlin/moe/xmcn/catsero/listeners/qwhitelist/WhiteListEditor.kt
@@ -13,27 +13,26 @@ class WhiteListEditor : Listener {
@EventHandler
fun onGroupMessage(e: MiraiGroupMessageEvent) {
try {
- val args = QPS.parse(e.message)
+ val args = QPS.parse(e.message, "whitelist")
if (args != null) {
if (
Configuration.USES_CONFIG.QWHITELIST.ENABLE
- && args[0].equals("whitelist", true)
&& e.botID == Configuration.Interface.getBotCode(Configuration.USES_CONFIG.GET_ONLINE_LIST.MIRAI.BOT)
&& e.groupID == Configuration.Interface.getGroupCode(Configuration.USES_CONFIG.GET_ONLINE_LIST.MIRAI.GROUP)
) {
if (Configuration.Interface.isQQOp(e.senderID)) {
- when (args[1]) {
+ when (args[0]) {
// 添加
"add" -> {
- if (args.size == 3) {
- if (!WhiteListDatabase().list.contains(args[2])) {
+ if (args.size == 2) {
+ if (!WhiteListDatabase().list.contains(args[1])) {
/*
list.getStringList("list").add(args[2])
list.save(configuration.whitelist_file)
list.load(configuration.whitelist_file)
*/
- if (WhiteListDatabase().insertList(args[2])) {
+ if (WhiteListDatabase().insertList(args[1])) {
MessageSender.sendGroup(
Configuration.I18N.QQ.USE.QWHITELIST.ADD_SUCCESS,
@@ -62,8 +61,8 @@ class WhiteListEditor : Listener {
// 移除
"remove" -> {
- if (args.size == 3) {
- if (WhiteListDatabase().list.contains(args[2])) {
+ if (args.size == 2) {
+ if (WhiteListDatabase().list.contains(args[1])) {
/*
list.getStringList("list").remove(args[2])
list.save(configuration.whitelist_file)
@@ -71,16 +70,16 @@ class WhiteListEditor : Listener {
*/
- if (WhiteListDatabase().removeList(args[2])) {
+ if (WhiteListDatabase().removeList(args[1])) {
// 如果玩家在线,将玩家踢出
if (
- Player.getUUIDByName(args[2]) != null
- && Player.getPlayer(args[2]).isOnline
+ Player.getUUIDByName(args[1]) != null
+ && Player.getPlayer(args[1]).isOnline
) {
Bukkit.getScheduler().runTask(
Configuration.plugin
) {
- Player.getOnlinePlayer(args[2])
+ Player.getOnlinePlayer(args[1])
.kickPlayer(
ChatColor.translateAlternateColorCodes(
'&',
@@ -117,8 +116,8 @@ class WhiteListEditor : Listener {
// 更新
"change" -> {
- if (args.size == 4) {
- if (WhiteListDatabase().list.contains(args[2])) {
+ if (args.size == 3) {
+ if (WhiteListDatabase().list.contains(args[1])) {
/*
list.getStringList("list").remove(args[2])
list.getStringList("list").add(args[3])
@@ -128,17 +127,17 @@ class WhiteListEditor : Listener {
*/
if (WhiteListDatabase()
- .updateList(args[2], args[3])
+ .updateList(args[1], args[2])
) {
// 如果玩家在线,将玩家踢出
if (
- Player.getUUIDByName(args[2]) != null
- && Player.getPlayer(args[2]).isOnline
+ Player.getUUIDByName(args[1]) != null
+ && Player.getPlayer(args[1]).isOnline
) {
Bukkit.getScheduler().runTask(
Configuration.plugin
) {
- Player.getOnlinePlayer(args[2])
+ Player.getOnlinePlayer(args[1])
.kickPlayer(
ChatColor.translateAlternateColorCodes(
'&',
diff --git a/src/main/resources/extra-configs/command-alias.yml b/src/main/resources/extra-configs/command-alias.yml
new file mode 100644
index 00000000..a73c386a
--- /dev/null
+++ b/src/main/resources/extra-configs/command-alias.yml
@@ -0,0 +1,14 @@
+# CatSero QQ CommandAlias Config
+# Generate by CatSero v@plugin.version@
+
+# 功能开关
+# true | false
+enable: false
+
+# 别名列表
+tps:
+ - ctps
+list:
+ - clist
+whitelist:
+ - cwl
\ No newline at end of file
diff --git a/src/main/resources/extra-configs/trchat.yml b/src/main/resources/extra-configs/trchat.yml
index e9830e21..c6ea38df 100644
--- a/src/main/resources/extra-configs/trchat.yml
+++ b/src/main/resources/extra-configs/trchat.yml
@@ -1,3 +1,5 @@
+# 聊天转发
chat-forward:
+ # 需要转发的频道
channel:
- - Normal
\ No newline at end of file
+ - Normal