mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-23 03:27:39 +08:00
命令名称声明规范移除"/"前缀,修复非命令却由于"@"符号导致事件被取消的问题
This commit is contained in:
parent
ce83e3284d
commit
9d0a1efc53
@ -1,6 +1,6 @@
|
|||||||
## Core
|
## Core
|
||||||
|
|
||||||
VERSION = 0.7.0.9
|
VERSION = 0.7.0.10
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
|
|
||||||
|
@ -4,6 +4,6 @@ package cc.sukazyo.cono.morny;
|
|||||||
* the final field that will be updated by gradle automatically.
|
* the final field that will be updated by gradle automatically.
|
||||||
*/
|
*/
|
||||||
public class GradleProjectConfigures {
|
public class GradleProjectConfigures {
|
||||||
public static final String VERSION = "0.7.0.9";
|
public static final String VERSION = "0.7.0.10";
|
||||||
public static final long COMPILE_TIMESTAMP = 1653199608824L;
|
public static final long COMPILE_TIMESTAMP = 1653200212040L;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import static cc.sukazyo.cono.morny.Log.logger;
|
|||||||
|
|
||||||
public class DirectMsgClear implements ISimpleCommand {
|
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]; }
|
@Nullable @Override public String[] getAliases () { return new String[0]; }
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import javax.annotation.Nullable;
|
|||||||
*/
|
*/
|
||||||
public class EventHack implements ITelegramCommand {
|
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; }
|
@Nullable @Override public String[] getAliases () { return null; }
|
||||||
@Nonnull @Override public String getParamRule () { return "[(user|group|any)]"; }
|
@Nonnull @Override public String getParamRule () { return "[(user|group|any)]"; }
|
||||||
@Nonnull @Override public String getDescription () { return "输出 bot 下一个获取到的事件序列化数据"; }
|
@Nonnull @Override public String getDescription () { return "输出 bot 下一个获取到的事件序列化数据"; }
|
||||||
|
@ -15,7 +15,7 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class GetUsernameAndId implements ITelegramCommand {
|
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; }
|
@Nullable @Override public String[] getAliases () { return null; }
|
||||||
@Nonnull @Override public String getParamRule () { return "[userid]"; }
|
@Nonnull @Override public String getParamRule () { return "[userid]"; }
|
||||||
@Nonnull @Override public String getDescription () { return "获取指定或回复的用户相关信息"; }
|
@Nonnull @Override public String getDescription () { return "获取指定或回复的用户相关信息"; }
|
||||||
|
@ -20,8 +20,11 @@ import static cc.sukazyo.untitled.util.telegram.formatting.MsgEscape.escapeHtml;
|
|||||||
*/
|
*/
|
||||||
public class Ip186Query {
|
public class Ip186Query {
|
||||||
|
|
||||||
|
public static final String CMD_IP = "ip";
|
||||||
|
public static final String CMD_WHOIS = "whois";
|
||||||
|
|
||||||
public static class Ip implements ITelegramCommand {
|
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]; }
|
@Nullable @Override public String[] getAliases () { return new String[0]; }
|
||||||
@Nonnull @Override public String getParamRule () { return "[ip]"; }
|
@Nonnull @Override public String getParamRule () { return "[ip]"; }
|
||||||
@Nonnull @Override public String getDescription () { return "通过 https://ip.186526.xyz 查询 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 {
|
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]; }
|
@Nullable @Override public String[] getAliases () { return new String[0]; }
|
||||||
@Nonnull @Override public String getParamRule () { return "[domain]"; }
|
@Nonnull @Override public String getParamRule () { return "[domain]"; }
|
||||||
@Nonnull @Override public String getDescription () { return "通过 https://ip.186526.xyz 查询域名资料"; }
|
@Nonnull @Override public String getDescription () { return "通过 https://ip.186526.xyz 查询域名资料"; }
|
||||||
@ -62,8 +65,8 @@ public class Ip186Query {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
IP186QueryResponse response = switch (command.getCommand()) {
|
IP186QueryResponse response = switch (command.getCommand()) {
|
||||||
case "/ip" -> IP186QueryHandler.queryIp(arg);
|
case CMD_IP -> IP186QueryHandler.queryIp(arg);
|
||||||
case "/whois" -> IP186QueryHandler.queryWhoisPretty(arg);
|
case CMD_WHOIS -> IP186QueryHandler.queryWhoisPretty(arg);
|
||||||
default -> throw new IllegalArgumentException("Unknown 186-IP query method " + command.getCommand());
|
default -> throw new IllegalArgumentException("Unknown 186-IP query method " + command.getCommand());
|
||||||
};
|
};
|
||||||
MornyCoeur.extra().exec(new SendMessage(
|
MornyCoeur.extra().exec(new SendMessage(
|
||||||
|
@ -159,7 +159,7 @@ public class MornyCommands {
|
|||||||
///
|
///
|
||||||
|
|
||||||
private static class ON implements ITelegramCommand {
|
private static class ON implements ITelegramCommand {
|
||||||
@Nonnull @Override public String getName () { return "/o"; }
|
@Nonnull @Override public String getName () { return "o"; }
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override public String[] getAliases () { return null; }
|
@Override public String[] getAliases () { return null; }
|
||||||
@Nonnull @Override public String getParamRule () { return ""; }
|
@Nonnull @Override public String getParamRule () { return ""; }
|
||||||
@ -175,8 +175,8 @@ public class MornyCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class Hello implements ITelegramCommand {
|
private static class Hello implements ITelegramCommand {
|
||||||
@Nonnull @Override public String getName () { return "/hello"; }
|
@Nonnull @Override public String getName () { return "hello"; }
|
||||||
@Nullable @Override public String[] getAliases () { return new String[]{"/hi"}; }
|
@Nullable @Override public String[] getAliases () { return new String[]{"hi"}; }
|
||||||
@Nonnull @Override public String getParamRule () { return ""; }
|
@Nonnull @Override public String getParamRule () { return ""; }
|
||||||
@Nonnull @Override public String getDescription () { return "打招呼"; }
|
@Nonnull @Override public String getDescription () { return "打招呼"; }
|
||||||
@Override public void execute (@Nonnull InputCommand command, @Nonnull Update event) { onCommandHelloExec(event); }
|
@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 {
|
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]; }
|
@Nullable @Override public String[] getAliases () { return new String[0]; }
|
||||||
@Nonnull @Override public String getParamRule () { return ""; }
|
@Nonnull @Override public String getParamRule () { return ""; }
|
||||||
@Nonnull @Override public String getDescription () { return "关闭 Bot (仅可信成员)"; }
|
@Nonnull @Override public String getDescription () { return "关闭 Bot (仅可信成员)"; }
|
||||||
@ -217,7 +217,7 @@ public class MornyCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class Version implements ITelegramCommand {
|
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; }
|
@Nullable @Override public String[] getAliases () { return null; }
|
||||||
@Nonnull @Override public String getParamRule () { return ""; }
|
@Nonnull @Override public String getParamRule () { return ""; }
|
||||||
@Nonnull @Override public String getDescription () { return "检查 Bot 版本信息"; }
|
@Nonnull @Override public String getDescription () { return "检查 Bot 版本信息"; }
|
||||||
@ -244,7 +244,7 @@ public class MornyCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class MornyRuntime implements ITelegramCommand {
|
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; }
|
@Nullable @Override public String[] getAliases () { return null; }
|
||||||
@Nonnull @Override public String getParamRule () { return ""; }
|
@Nonnull @Override public String getParamRule () { return ""; }
|
||||||
@Nonnull @Override public String getDescription () { return "获取 Bot 运行时信息(包括版本号)"; }
|
@Nonnull @Override public String getDescription () { return "获取 Bot 运行时信息(包括版本号)"; }
|
||||||
@ -309,7 +309,7 @@ public class MornyCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class Jrrp implements ITelegramCommand {
|
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; }
|
@Nullable @Override public String[] getAliases () { return null; }
|
||||||
@Nonnull @Override public String getParamRule () { return ""; }
|
@Nonnull @Override public String getParamRule () { return ""; }
|
||||||
@Nonnull @Override public String getDescription () { return "获取 (假的) jrrp"; }
|
@Nonnull @Override public String getDescription () { return "获取 (假的) jrrp"; }
|
||||||
@ -329,7 +329,7 @@ public class MornyCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class SaveData implements ITelegramCommand {
|
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; }
|
@Nullable @Override public String[] getAliases () { return null; }
|
||||||
@Nonnull @Override public String getParamRule () { return ""; }
|
@Nonnull @Override public String getParamRule () { return ""; }
|
||||||
@Nonnull @Override public String getDescription () { return "保存缓存数据到文件(仅可信成员)"; }
|
@Nonnull @Override public String getDescription () { return "保存缓存数据到文件(仅可信成员)"; }
|
||||||
|
@ -16,7 +16,7 @@ import static cc.sukazyo.untitled.util.telegram.formatting.MsgEscape.escapeHtml;
|
|||||||
|
|
||||||
public class Nbnhhsh implements ITelegramCommand {
|
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; }
|
@Nullable @Override public String[] getAliases () { return null; }
|
||||||
@Nonnull @Override public String getParamRule () { return "[text]"; }
|
@Nonnull @Override public String getParamRule () { return "[text]"; }
|
||||||
@Nonnull @Override public String getDescription () { return "检索文本内 nbnhhsh 词条"; }
|
@Nonnull @Override public String getDescription () { return "检索文本内 nbnhhsh 词条"; }
|
||||||
|
@ -13,7 +13,7 @@ import javax.annotation.Nullable;
|
|||||||
public class 喵呜 {
|
public class 喵呜 {
|
||||||
|
|
||||||
public static class 抱抱 implements ISimpleCommand {
|
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]; }
|
@Nullable @Override public String[] getAliases () { return new String[0]; }
|
||||||
@Override public void execute (@Nonnull InputCommand command, @Nonnull Update event) {
|
@Override public void execute (@Nonnull InputCommand command, @Nonnull Update event) {
|
||||||
MornyCoeur.extra().exec(new SendMessage(
|
MornyCoeur.extra().exec(new SendMessage(
|
||||||
@ -24,7 +24,7 @@ public class 喵呜 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class 揉揉 implements ISimpleCommand {
|
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]; }
|
@Nullable @Override public String[] getAliases () { return new String[0]; }
|
||||||
@Override public void execute (@Nonnull InputCommand command, @Nonnull Update event) {
|
@Override public void execute (@Nonnull InputCommand command, @Nonnull Update event) {
|
||||||
MornyCoeur.extra().exec(new SendMessage(
|
MornyCoeur.extra().exec(new SendMessage(
|
||||||
@ -35,7 +35,7 @@ public class 喵呜 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class 蹭蹭 implements ISimpleCommand {
|
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]; }
|
@Nullable @Override public String[] getAliases () { return new String[0]; }
|
||||||
@Override public void execute (@Nonnull InputCommand command, @Nonnull Update event) {
|
@Override public void execute (@Nonnull InputCommand command, @Nonnull Update event) {
|
||||||
MornyCoeur.extra().exec(new SendMessage(
|
MornyCoeur.extra().exec(new SendMessage(
|
||||||
@ -46,7 +46,7 @@ public class 喵呜 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class 贴贴 implements ISimpleCommand {
|
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]; }
|
@Nullable @Override public String[] getAliases () { return new String[0]; }
|
||||||
@Override public void execute (@Nonnull InputCommand command, @Nonnull Update event) {
|
@Override public void execute (@Nonnull InputCommand command, @Nonnull Update event) {
|
||||||
MornyCoeur.extra().exec(new SendMessage(
|
MornyCoeur.extra().exec(new SendMessage(
|
||||||
|
@ -13,7 +13,7 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
public class 私わね implements ISimpleCommand {
|
public class 私わね implements ISimpleCommand {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override public String getName () { return "/me"; }
|
@Override public String getName () { return "me"; }
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override public String[] getAliases () { return null; }
|
@Override public String[] getAliases () { return null; }
|
||||||
|
@ -12,10 +12,10 @@ public class OnTelegramCommand extends EventListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMessage (@Nonnull Update event) {
|
public boolean onMessage (@Nonnull Update event) {
|
||||||
if (event.message().text() == null) {
|
if (event.message().text() == null || !event.message().text().startsWith("/")) {
|
||||||
return false; // 检测到无消息文本,忽略掉命令处理
|
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())) {
|
if (command.getTarget() != null && !MornyCoeur.getUsername().equals(command.getTarget())) {
|
||||||
return true; // 检测到命令并非针对 morny,退出整个事件处理链
|
return true; // 检测到命令并非针对 morny,退出整个事件处理链
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user