diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/MiraiSongPlugin.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/MiraiSongPlugin.java index af4c0ff..0eec8fd 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/MiraiSongPlugin.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/MiraiSongPlugin.java @@ -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; @@ -179,13 +180,16 @@ private BiConsumer 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; }); }; } @@ -215,11 +219,15 @@ private BiConsumer 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); diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/Utils.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/Utils.java index cc4e8ac..a559b39 100644 --- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/Utils.java +++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/Utils.java @@ -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; } @@ -188,7 +188,7 @@ public static Contact getProperReceiver(MessageEvent ev) { } /** - * Execute command,wait until finished.
+ * Execute OS command,wait until finished.
* 执行操作平台命令,等待完成。 * * @param commandStr the command string
@@ -208,7 +208,7 @@ public static void exeCmd(String... commandStr) { } /** - * Execute command,wait until finished.
+ * Execute OS command,wait until finished.
* 执行操作平台命令,等待完成。 * * @param commandStr the command string