diff --git a/gradle.properties b/gradle.properties index 2e99ea0..d8b400a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ ## Core -VERSION = 0.7.0.9 +VERSION = 0.7.0.10 # dependencies diff --git a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java index 3bee94b..f42d08b 100644 --- a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java +++ b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java @@ -4,6 +4,6 @@ package cc.sukazyo.cono.morny; * the final field that will be updated by gradle automatically. */ public class GradleProjectConfigures { - public static final String VERSION = "0.7.0.9"; - public static final long COMPILE_TIMESTAMP = 1653199608824L; + public static final String VERSION = "0.7.0.10"; + public static final long COMPILE_TIMESTAMP = 1653200212040L; } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/DirectMsgClear.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/DirectMsgClear.java index 7e3cc82..7c66a8f 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/command/DirectMsgClear.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/DirectMsgClear.java @@ -14,7 +14,7 @@ import static cc.sukazyo.cono.morny.Log.logger; public class DirectMsgClear implements ISimpleCommand { - @Nonnull @Override public String getName () { return "/r"; } + @Nonnull @Override public String getName () { return "r"; } @Nullable @Override public String[] getAliases () { return new String[0]; } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/EventHack.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/EventHack.java index b43df8d..18edc7b 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/command/EventHack.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/EventHack.java @@ -18,7 +18,7 @@ import javax.annotation.Nullable; */ public class EventHack implements ITelegramCommand { - @Nonnull @Override public String getName () { return "/event_hack"; } + @Nonnull @Override public String getName () { return "event_hack"; } @Nullable @Override public String[] getAliases () { return null; } @Nonnull @Override public String getParamRule () { return "[(user|group|any)]"; } @Nonnull @Override public String getDescription () { return "输出 bot 下一个获取到的事件序列化数据"; } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/GetUsernameAndId.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/GetUsernameAndId.java index f7d136f..da67bb7 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/command/GetUsernameAndId.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/GetUsernameAndId.java @@ -15,7 +15,7 @@ import javax.annotation.Nullable; public class GetUsernameAndId implements ITelegramCommand { - @Nonnull @Override public String getName () { return "/user"; } + @Nonnull @Override public String getName () { return "user"; } @Nullable @Override public String[] getAliases () { return null; } @Nonnull @Override public String getParamRule () { return "[userid]"; } @Nonnull @Override public String getDescription () { return "获取指定或回复的用户相关信息"; } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/Ip186Query.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/Ip186Query.java index 7a47390..1390096 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/command/Ip186Query.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/Ip186Query.java @@ -20,8 +20,11 @@ import static cc.sukazyo.untitled.util.telegram.formatting.MsgEscape.escapeHtml; */ public class Ip186Query { + public static final String CMD_IP = "ip"; + public static final String CMD_WHOIS = "whois"; + public static class Ip implements ITelegramCommand { - @Nonnull @Override public String getName () { return "/ip"; } + @Nonnull @Override public String getName () { return CMD_IP; } @Nullable @Override public String[] getAliases () { return new String[0]; } @Nonnull @Override public String getParamRule () { return "[ip]"; } @Nonnull @Override public String getDescription () { return "通过 https://ip.186526.xyz 查询 ip 资料"; } @@ -29,7 +32,7 @@ public class Ip186Query { } public static class Whois implements ITelegramCommand { - @Nonnull @Override public String getName () { return "/whois"; } + @Nonnull @Override public String getName () { return CMD_WHOIS; } @Nullable @Override public String[] getAliases () { return new String[0]; } @Nonnull @Override public String getParamRule () { return "[domain]"; } @Nonnull @Override public String getDescription () { return "通过 https://ip.186526.xyz 查询域名资料"; } @@ -62,8 +65,8 @@ public class Ip186Query { try { IP186QueryResponse response = switch (command.getCommand()) { - case "/ip" -> IP186QueryHandler.queryIp(arg); - case "/whois" -> IP186QueryHandler.queryWhoisPretty(arg); + case CMD_IP -> IP186QueryHandler.queryIp(arg); + case CMD_WHOIS -> IP186QueryHandler.queryWhoisPretty(arg); default -> throw new IllegalArgumentException("Unknown 186-IP query method " + command.getCommand()); }; MornyCoeur.extra().exec(new SendMessage( diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/MornyCommands.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/MornyCommands.java index 7c72538..9e2efe6 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/command/MornyCommands.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/MornyCommands.java @@ -159,7 +159,7 @@ public class MornyCommands { /// private static class ON implements ITelegramCommand { - @Nonnull @Override public String getName () { return "/o"; } + @Nonnull @Override public String getName () { return "o"; } @Nullable @Override public String[] getAliases () { return null; } @Nonnull @Override public String getParamRule () { return ""; } @@ -175,8 +175,8 @@ public class MornyCommands { } private static class Hello implements ITelegramCommand { - @Nonnull @Override public String getName () { return "/hello"; } - @Nullable @Override public String[] getAliases () { return new String[]{"/hi"}; } + @Nonnull @Override public String getName () { return "hello"; } + @Nullable @Override public String[] getAliases () { return new String[]{"hi"}; } @Nonnull @Override public String getParamRule () { return ""; } @Nonnull @Override public String getDescription () { return "打招呼"; } @Override public void execute (@Nonnull InputCommand command, @Nonnull Update event) { onCommandHelloExec(event); } @@ -191,7 +191,7 @@ public class MornyCommands { } private static class Exit implements ITelegramCommand { - @Nonnull @Override public String getName () { return "/exit"; } + @Nonnull @Override public String getName () { return "exit"; } @Nullable @Override public String[] getAliases () { return new String[0]; } @Nonnull @Override public String getParamRule () { return ""; } @Nonnull @Override public String getDescription () { return "关闭 Bot (仅可信成员)"; } @@ -217,7 +217,7 @@ public class MornyCommands { } private static class Version implements ITelegramCommand { - @Nonnull @Override public String getName () { return "/version"; } + @Nonnull @Override public String getName () { return "version"; } @Nullable @Override public String[] getAliases () { return null; } @Nonnull @Override public String getParamRule () { return ""; } @Nonnull @Override public String getDescription () { return "检查 Bot 版本信息"; } @@ -244,7 +244,7 @@ public class MornyCommands { } private static class MornyRuntime implements ITelegramCommand { - @Nonnull @Override public String getName () { return "/runtime"; } + @Nonnull @Override public String getName () { return "runtime"; } @Nullable @Override public String[] getAliases () { return null; } @Nonnull @Override public String getParamRule () { return ""; } @Nonnull @Override public String getDescription () { return "获取 Bot 运行时信息(包括版本号)"; } @@ -309,7 +309,7 @@ public class MornyCommands { } private static class Jrrp implements ITelegramCommand { - @Nonnull @Override public String getName () { return "/jrrp"; } + @Nonnull @Override public String getName () { return "jrrp"; } @Nullable @Override public String[] getAliases () { return null; } @Nonnull @Override public String getParamRule () { return ""; } @Nonnull @Override public String getDescription () { return "获取 (假的) jrrp"; } @@ -329,7 +329,7 @@ public class MornyCommands { } private static class SaveData implements ITelegramCommand { - @Nonnull @Override public String getName () { return "/save"; } + @Nonnull @Override public String getName () { return "save"; } @Nullable @Override public String[] getAliases () { return null; } @Nonnull @Override public String getParamRule () { return ""; } @Nonnull @Override public String getDescription () { return "保存缓存数据到文件(仅可信成员)"; } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/Nbnhhsh.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/Nbnhhsh.java index b72127d..fced75b 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/command/Nbnhhsh.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/Nbnhhsh.java @@ -16,7 +16,7 @@ import static cc.sukazyo.untitled.util.telegram.formatting.MsgEscape.escapeHtml; public class Nbnhhsh implements ITelegramCommand { - @Nonnull @Override public String getName () { return "/nbnhhsh"; } + @Nonnull @Override public String getName () { return "nbnhhsh"; } @Nullable @Override public String[] getAliases () { return null; } @Nonnull @Override public String getParamRule () { return "[text]"; } @Nonnull @Override public String getDescription () { return "检索文本内 nbnhhsh 词条"; } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/喵呜.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/喵呜.java index ca31006..67d644a 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/command/喵呜.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/喵呜.java @@ -13,7 +13,7 @@ import javax.annotation.Nullable; public class 喵呜 { public static class 抱抱 implements ISimpleCommand { - @Nonnull @Override public String getName () { return "/抱抱"; } + @Nonnull @Override public String getName () { return "抱抱"; } @Nullable @Override public String[] getAliases () { return new String[0]; } @Override public void execute (@Nonnull InputCommand command, @Nonnull Update event) { MornyCoeur.extra().exec(new SendMessage( @@ -24,7 +24,7 @@ public class 喵呜 { } public static class 揉揉 implements ISimpleCommand { - @Nonnull @Override public String getName () { return "/揉揉"; } + @Nonnull @Override public String getName () { return "揉揉"; } @Nullable @Override public String[] getAliases () { return new String[0]; } @Override public void execute (@Nonnull InputCommand command, @Nonnull Update event) { MornyCoeur.extra().exec(new SendMessage( @@ -35,7 +35,7 @@ public class 喵呜 { } public static class 蹭蹭 implements ISimpleCommand { - @Nonnull @Override public String getName () { return "/蹭蹭"; } + @Nonnull @Override public String getName () { return "蹭蹭"; } @Nullable @Override public String[] getAliases () { return new String[0]; } @Override public void execute (@Nonnull InputCommand command, @Nonnull Update event) { MornyCoeur.extra().exec(new SendMessage( @@ -46,7 +46,7 @@ public class 喵呜 { } public static class 贴贴 implements ISimpleCommand { - @Nonnull @Override public String getName () { return "/贴贴"; } + @Nonnull @Override public String getName () { return "贴贴"; } @Nullable @Override public String[] getAliases () { return new String[0]; } @Override public void execute (@Nonnull InputCommand command, @Nonnull Update event) { MornyCoeur.extra().exec(new SendMessage( diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/私わね.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/私わね.java index e06f66a..a8ad800 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/command/私わね.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/私わね.java @@ -13,7 +13,7 @@ import java.util.concurrent.ThreadLocalRandom; public class 私わね implements ISimpleCommand { @Nonnull - @Override public String getName () { return "/me"; } + @Override public String getName () { return "me"; } @Nullable @Override public String[] getAliases () { return null; } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnTelegramCommand.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnTelegramCommand.java index e0f2419..0c632ab 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnTelegramCommand.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnTelegramCommand.java @@ -12,10 +12,10 @@ public class OnTelegramCommand extends EventListener { @Override public boolean onMessage (@Nonnull Update event) { - if (event.message().text() == null) { - return false; // 检测到无消息文本,忽略掉命令处理 + if (event.message().text() == null || !event.message().text().startsWith("/")) { + return false; // 检测到非(命令格式)文本,忽略掉命令处理 } - final InputCommand command = new InputCommand(event.message().text()); + final InputCommand command = new InputCommand(event.message().text().substring(1)); if (command.getTarget() != null && !MornyCoeur.getUsername().equals(command.getTarget())) { return true; // 检测到命令并非针对 morny,退出整个事件处理链 }