mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-22 19:24:53 +08:00
修改了 "meow-set" 部分的文案,并为其添加了特异化回复的功能,修复其以及 --report-to 的 bug
- 修复了上次提交的 --report-to 参数没有被正确处理问题 - 创建了一个新的补丁事件,修复了 meow-set 无法使用的问题
This commit is contained in:
parent
3689962cb3
commit
fbbfe73ac1
@ -5,7 +5,7 @@ MORNY_ARCHIVE_NAME = morny-coeur
|
||||
MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono
|
||||
MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s
|
||||
|
||||
VERSION = 1.0.0-alpha6
|
||||
VERSION = 1.0.0-beta1
|
||||
|
||||
USE_DELTA = false
|
||||
VERSION_DELTA =
|
||||
|
@ -162,6 +162,7 @@ public class ServerMain {
|
||||
continue;
|
||||
}
|
||||
case "--report-to" -> {
|
||||
i++;
|
||||
config.reportToChat = Long.parseLong(args[i]);
|
||||
continue;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package cc.sukazyo.cono.morny.bot.command;
|
||||
import cc.sukazyo.cono.morny.BuildConfig;
|
||||
import cc.sukazyo.cono.morny.MornyCoeur;
|
||||
import cc.sukazyo.cono.morny.MornySystem;
|
||||
import cc.sukazyo.cono.morny.bot.event.OnUniMeowTrigger;
|
||||
import cc.sukazyo.cono.morny.daemon.MornyReport;
|
||||
import cc.sukazyo.cono.morny.data.MornyJrrp;
|
||||
import cc.sukazyo.cono.morny.data.TelegramStickers;
|
||||
@ -83,12 +84,15 @@ public class MornyCommands {
|
||||
|
||||
// 统一注册这些奇怪的东西&.&
|
||||
register(
|
||||
new 私わね(),
|
||||
new 喵呜.Progynova()
|
||||
);
|
||||
// special: 注册出于兼容使用的特别 event 的数据
|
||||
OnUniMeowTrigger.register(
|
||||
new 喵呜.抱抱(),
|
||||
new 喵呜.揉揉(),
|
||||
new 喵呜.蹭蹭(),
|
||||
new 喵呜.贴贴(),
|
||||
new 私わね(),
|
||||
new 喵呜.Progynova()
|
||||
new 喵呜.贴贴()
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package cc.sukazyo.cono.morny.bot.command;
|
||||
import cc.sukazyo.cono.morny.MornyCoeur;
|
||||
import cc.sukazyo.cono.morny.data.TelegramStickers;
|
||||
import cc.sukazyo.cono.morny.util.tgapi.InputCommand;
|
||||
import com.pengrad.telegrambot.model.Message;
|
||||
import com.pengrad.telegrambot.model.Update;
|
||||
import com.pengrad.telegrambot.model.request.ParseMode;
|
||||
import com.pengrad.telegrambot.request.SendMessage;
|
||||
@ -11,6 +12,16 @@ import com.pengrad.telegrambot.request.SendSticker;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* <b>WARNING</b> that {@link cc.sukazyo.cono.morny.bot.event.OnTelegramCommand}
|
||||
* 并不能够处理非 english word 字符之外的命令.
|
||||
* <p>
|
||||
* 出于这个限制,以下几个命令目前都无法使用
|
||||
* @see 抱抱
|
||||
* @see 揉揉
|
||||
* @see 蹭蹭
|
||||
* @see 贴贴
|
||||
*/
|
||||
@SuppressWarnings("NonAsciiCharacters")
|
||||
public class 喵呜 {
|
||||
|
||||
@ -18,10 +29,7 @@ public class 喵呜 {
|
||||
@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(),
|
||||
"抱抱——"
|
||||
));
|
||||
replyingSet(event, "抱抱", "抱抱");
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,10 +37,7 @@ public class 喵呜 {
|
||||
@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"
|
||||
));
|
||||
replyingSet(event, "蹭蹭", "摸摸");
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,10 +45,7 @@ public class 喵呜 {
|
||||
@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(),
|
||||
"喵呜~-"
|
||||
));
|
||||
replyingSet(event, "揉揉", "蹭蹭");
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,13 +53,19 @@ public class 喵呜 {
|
||||
@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(),
|
||||
"<tg-spoiler>(贴贴喵呜&.&)</tg-spoiler>"
|
||||
).parseMode(ParseMode.HTML));
|
||||
replyingSet(event, "贴贴", "贴贴");
|
||||
}
|
||||
}
|
||||
|
||||
private static void replyingSet (@Nonnull Update event, @Nonnull String whileRec, @Nonnull String whileNew) {
|
||||
final boolean isNew = event.message().replyToMessage() == null;
|
||||
final Message target = isNew ? event.message() : event.message().replyToMessage();
|
||||
MornyCoeur.extra().exec(new SendMessage(
|
||||
event.message().chat().id(),
|
||||
isNew ? whileNew : whileRec
|
||||
).replyToMessageId(target.messageId()).parseMode(ParseMode.HTML));
|
||||
}
|
||||
|
||||
public static class Progynova implements ITelegramCommand {
|
||||
@Nonnull @Override public String getName () { return "install"; }
|
||||
@Nullable @Override public String[] getAliases () { return new String[0]; }
|
||||
|
@ -16,6 +16,7 @@ public class EventListeners {
|
||||
public static final OnCallMsgSend CALL_MSG_SEND = new OnCallMsgSend();
|
||||
public static final OnMedicationNotifyApply MEDICATION_NOTIFY_APPLY = new OnMedicationNotifyApply();
|
||||
public static final OnRandomlyTriggered RANDOMLY_TRIGGERED = new OnRandomlyTriggered();
|
||||
public static final OnUniMeowTrigger UNI_MEOW_TRIGGER = new OnUniMeowTrigger();
|
||||
|
||||
public static void registerAllListeners () {
|
||||
EventListenerManager.addListener(
|
||||
@ -24,6 +25,7 @@ public class EventListeners {
|
||||
/* write functional event behind here */
|
||||
// KUOHUANHUAN_NEED_SLEEP,
|
||||
COMMANDS_LISTENER,
|
||||
UNI_MEOW_TRIGGER,
|
||||
RANDOMLY_TRIGGERED,
|
||||
USER_RANDOMS,
|
||||
USER_SLASH_ACTION,
|
||||
|
@ -0,0 +1,36 @@
|
||||
package cc.sukazyo.cono.morny.bot.event;
|
||||
|
||||
import cc.sukazyo.cono.morny.bot.api.EventListener;
|
||||
import cc.sukazyo.cono.morny.bot.command.ISimpleCommand;
|
||||
import cc.sukazyo.cono.morny.util.tgapi.InputCommand;
|
||||
import com.pengrad.telegrambot.model.Update;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class OnUniMeowTrigger extends EventListener {
|
||||
|
||||
private static final Map<String, ISimpleCommand> triggers = new HashMap<>();
|
||||
|
||||
public static void register (ISimpleCommand... list) {
|
||||
for (ISimpleCommand cmd : list)
|
||||
triggers.put(cmd.getName(), cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMessage (@Nonnull Update event) {
|
||||
if (event.message().text() == null) return false;
|
||||
AtomicBoolean ok = new AtomicBoolean(false);
|
||||
triggers.forEach((name, command) -> {
|
||||
name = "/" + name;
|
||||
if (name.equals(event.message().text())) {
|
||||
command.execute(new InputCommand(name), event);
|
||||
ok.set(true);
|
||||
}
|
||||
});
|
||||
return ok.get();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user