Skip to content

Commit

Permalink
fix minor problems
Browse files Browse the repository at this point in the history
  • Loading branch information
khjxiaogu committed Aug 26, 2022
1 parent a3380e8 commit 61eef74
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
20 changes: 14 additions & 6 deletions src/main/java/com/khjxiaogu/MiraiSongPlugin/MiraiSongPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import net.mamoe.mirai.event.events.GroupMessageEvent;
import net.mamoe.mirai.event.events.MessageEvent;
import net.mamoe.mirai.event.events.StrangerMessageEvent;
import net.mamoe.mirai.message.data.Message;
import net.mamoe.mirai.utils.MiraiLogger;
import net.mamoe.yamlkt.Yaml;
import net.mamoe.yamlkt.YamlElement;
Expand Down Expand Up @@ -179,13 +180,16 @@ private BiConsumer<MessageEvent, String[]> makeTemplate(String source, String ca
return;
}
try {
Utils.getProperReceiver(event).sendMessage(cb.process(mi, Utils.getProperReceiver(event)));
Message m=cb.process(mi, Utils.getProperReceiver(event));
if(m!=null) {
Utils.getProperReceiver(event).sendMessage(m);
return;
}
} catch (Throwable t) {
this.getLogger().debug(t);
// this.getLogger().
Utils.getProperReceiver(event).sendMessage(unavailableShare);
return;
}
Utils.getProperReceiver(event).sendMessage(unavailableShare);
return;
});
};
}
Expand Down Expand Up @@ -215,11 +219,15 @@ private BiConsumer<MessageEvent, String[]> makeSearchesTemplate(String card) {
continue;
}
try {
Utils.getProperReceiver(event).sendMessage(cb.process(mi, Utils.getProperReceiver(event)));
Message m=cb.process(mi, Utils.getProperReceiver(event));
if(m!=null) {
Utils.getProperReceiver(event).sendMessage(m);
return;
}
} catch (Throwable t) {
this.getLogger().debug(t);
Utils.getProperReceiver(event).sendMessage(unavailableShare);
}
Utils.getProperReceiver(event).sendMessage(unavailableShare);
return;
}
Utils.getProperReceiver(event).sendMessage(unfoundSong);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/khjxiaogu/MiraiSongPlugin/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public static String getPlainText(MessageChain msg) {
*/
public static String removeLeadings(String leading, String orig) {
if (orig.startsWith(leading))
return orig.substring(leading.length()).replace(leading, "").trim();
return orig.substring(leading.length()).trim();
return orig;
}

Expand All @@ -188,7 +188,7 @@ public static Contact getProperReceiver(MessageEvent ev) {
}

/**
* Execute command,wait until finished.<br>
* Execute OS command,wait until finished.<br>
* 执行操作平台命令,等待完成。
*
* @param commandStr the command string<br>
Expand All @@ -208,7 +208,7 @@ public static void exeCmd(String... commandStr) {
}

/**
* Execute command,wait until finished.<br>
* Execute OS command,wait until finished.<br>
* 执行操作平台命令,等待完成。
*
* @param commandStr the command string<br>
Expand Down

0 comments on commit 61eef74

Please sign in to comment.