Skip to content

Commit

Permalink
Merge pull request #157 from SimbaMC/forge_to_upstream
Browse files Browse the repository at this point in the history
Implement new # symbol for QQ binding -- Forge
  • Loading branch information
cnlimiter authored Jul 30, 2024
2 parents ab42854 + b7e6a20 commit 3eee6a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions forge/src/main/java/cn/evole/mods/mcbot/cmds/CmdApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ public static void invokeCommandGroup(String msg, GroupMessageEvent event) {
// 如果指令包含list,则强行以非管理员身份执行
CustomCmdHandler.INSTANCE.getCustomCmds().stream()
.filter(customCmd -> customCmd.getRequirePermission() < 1 && performedCommand.equals(customCmd.getCmdAlies()))
.forEach(customCmd -> GroupCmd(event.getGroupId(), BotUtils.varParse(customCmd, originCommand), false, customCmd.isVanishSupport()));
.forEach(customCmd -> GroupCmd(event.getGroupId(), BotUtils.varParse(customCmd, originCommand, event), false, customCmd.isVanishSupport()));
}else{
if (BotUtils.groupAdminParse(event)) {
CustomCmdHandler.INSTANCE.getCustomCmds().stream()
.filter(customCmd -> performedCommand.equals(customCmd.getCmdAlies()))
.forEach(customCmd -> GroupCmd(event.getGroupId(), BotUtils.varParse(customCmd, originCommand), true, customCmd.isVanishSupport()));//admin
.forEach(customCmd -> GroupCmd(event.getGroupId(), BotUtils.varParse(customCmd, originCommand, event), true, customCmd.isVanishSupport()));//admin
} else
CustomCmdHandler.INSTANCE.getCustomCmds().stream()
.filter(customCmd -> customCmd.getRequirePermission() < 1 && performedCommand.equals(customCmd.getCmdAlies()))
.forEach(customCmd -> GroupCmd(event.getGroupId(), BotUtils.varParse(customCmd, originCommand), false, customCmd.isVanishSupport()));
.forEach(customCmd -> GroupCmd(event.getGroupId(), BotUtils.varParse(customCmd, originCommand, event), false, customCmd.isVanishSupport()));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private static boolean isVar(String msg) {
AtomicBoolean match = new AtomicBoolean(false);
CustomCmdHandler.INSTANCE.getCustomCmds().forEach(
cmd -> {
if (cmd.getCmdContent().contains("%")) {//是否变量模板
if (cmd.getCmdContent().contains("%") | cmd.getCmdContent().contains("#")) {//是否变量模板
if (msg.contains(cmd.getCmdAlies()))//去除命令符号
match.set(true);
}
Expand All @@ -43,11 +43,12 @@ private static boolean isVar(String msg) {
* @param cmd q群指令
* @return 处理完的指令
*/
public static String varParse(CustomCmd customCmd, String cmd) {
public static String varParse(CustomCmd customCmd, String cmd, GroupMessageEvent event) {
String returnCmd = "";
if (isVar(cmd)) {//存在变量
val replaceContent = customCmd.getCmdContent().split("%")[0].trim();
returnCmd = cmd.replace(customCmd.getCmdAlies(), replaceContent);//返回q群指令
returnCmd = returnCmd.replace("#", event.getSender().getUserId());
} else returnCmd = customCmd.getCmdContent();//返回普通自定义命令指令
return returnCmd;
}
Expand Down

0 comments on commit 3eee6a6

Please sign in to comment.