diff --git a/gradle.properties b/gradle.properties index c50def2..6df2753 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ ## Core -VERSION = 0.5.0.5 +VERSION = 0.5.0.6 # dependencies diff --git a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java index 08e9636..f48072a 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.5.0.5"; - public static final long COMPILE_TIMESTAMP = 1644309862037L; + public static final String VERSION = "0.5.0.6"; + public static final long COMPILE_TIMESTAMP = 1644378359640L; } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/ISimpleCommand.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/ISimpleCommand.java new file mode 100644 index 0000000..0f3fea2 --- /dev/null +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/ISimpleCommand.java @@ -0,0 +1,19 @@ +package cc.sukazyo.cono.morny.bot.command; + +import cc.sukazyo.untitled.util.telegram.object.InputCommand; +import com.pengrad.telegrambot.model.Update; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public interface ISimpleCommand { + + @Nonnull + String getName(); + + @Nullable + String[] getAliases(); + + void execute (@Nonnull InputCommand command, @Nonnull Update event); + +} diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/ITelegramCommand.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/ITelegramCommand.java index 75f6186..b090a95 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/command/ITelegramCommand.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/ITelegramCommand.java @@ -1,23 +1,12 @@ package cc.sukazyo.cono.morny.bot.command; -import cc.sukazyo.untitled.util.telegram.object.InputCommand; -import com.pengrad.telegrambot.model.Update; - import javax.annotation.Nonnull; -import javax.annotation.Nullable; -public interface ITelegramCommand { +public interface ITelegramCommand extends ISimpleCommand { - @Nonnull - String getName(); - - @Nullable - String[] getAliases(); @Nonnull String getParamRule(); @Nonnull String getDescription(); - void execute (@Nonnull InputCommand command, @Nonnull Update event); - } 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 19f3078..d2fc28b 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 @@ -29,9 +29,9 @@ import static cc.sukazyo.untitled.util.telegram.formatting.MsgEscape.escapeHtml; public class MornyCommands { - private final Map commands = new LinkedHashMap<>(); + private final Map commands = new LinkedHashMap<>(); - private void pushCommandTo (@Nonnull String name, @Nonnull ITelegramCommand instance) { + private void pushCommandTo (@Nonnull String name, @Nonnull ISimpleCommand instance) { if (commands.containsKey(name)) { logger.warn(String.format(""" Telegram command instance named "%s" already exists and will be override by another command instance @@ -45,8 +45,8 @@ public class MornyCommands { commands.put(name, instance); } - public void register (@Nonnull ITelegramCommand... list) { - for (ITelegramCommand instance : list) { + public void register (@Nonnull ISimpleCommand... list) { + for (ISimpleCommand instance : list) { final String[] aliases = instance.getAliases(); pushCommandTo(instance.getName(), instance); if (aliases!=null) for (String alias : aliases) pushCommandTo(alias, instance); @@ -70,6 +70,14 @@ public class MornyCommands { new Exit() ); + // 统一注册这些奇怪的东西&.& + register( + new 喵呜.抱抱(), + new 喵呜.揉揉(), + new 喵呜.蹭蹭(), + new 喵呜.贴贴() + ); + } public boolean execute (@Nonnull InputCommand command, @Nonnull Update event) { @@ -99,11 +107,11 @@ public class MornyCommands { public BotCommand[] getCommandListTelegram () { final List telegramFormatListing = new ArrayList<>(); commands.forEach((regKey, command) -> { - if (regKey.equals(command.getName())) { + if (command instanceof ITelegramCommand && regKey.equals(command.getName())) { telegramFormatListing.add(formatTelegramCommandListLine( command.getName(), - command.getParamRule(), - command.getDescription() + ((ITelegramCommand)command).getParamRule(), + ((ITelegramCommand)command).getDescription() )); if (command.getAliases() != null) for (String alias : command.getAliases()) { telegramFormatListing.add(formatTelegramCommandListLine(alias, "", "↑")); diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/喵呜.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/喵呜.java new file mode 100644 index 0000000..ca31006 --- /dev/null +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/喵呜.java @@ -0,0 +1,59 @@ +package cc.sukazyo.cono.morny.bot.command; + +import cc.sukazyo.cono.morny.MornyCoeur; +import cc.sukazyo.untitled.util.telegram.object.InputCommand; +import com.pengrad.telegrambot.model.Update; +import com.pengrad.telegrambot.model.request.ParseMode; +import com.pengrad.telegrambot.request.SendMessage; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +@SuppressWarnings("NonAsciiCharacters") +public class 喵呜 { + + public static class 抱抱 implements ISimpleCommand { + @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( + event.message().chat().id(), + "抱抱——" + )); + } + } + + public static class 揉揉 implements ISimpleCommand { + @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( + event.message().chat().id(), + "蹭蹭w" + )); + } + } + + public static class 蹭蹭 implements ISimpleCommand { + @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( + event.message().chat().id(), + "喵呜~-" + )); + } + } + + public static class 贴贴 implements ISimpleCommand { + @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( + event.message().chat().id(), + "(贴贴喵呜&.&)" + ).parseMode(ParseMode.HTML)); + } + } + +}