mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-23 03:27:39 +08:00
add a function "if something?" to OnUserRandoms
- and now uses @Deprecated not @SuppressWarnings("unused") to tag those unused event.
This commit is contained in:
parent
8e28bbbce1
commit
17c29036b3
@ -5,7 +5,7 @@ MORNY_ARCHIVE_NAME = morny-coeur
|
|||||||
MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono
|
MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono
|
||||||
MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s
|
MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s
|
||||||
|
|
||||||
VERSION = 1.0.0-RC3
|
VERSION = 1.0.0-RC3.1
|
||||||
|
|
||||||
USE_DELTA = false
|
USE_DELTA = false
|
||||||
VERSION_DELTA =
|
VERSION_DELTA =
|
||||||
|
@ -5,13 +5,13 @@ import cc.sukazyo.cono.morny.bot.api.EventListenerManager;
|
|||||||
public class EventListeners {
|
public class EventListeners {
|
||||||
|
|
||||||
public static final OnTelegramCommand COMMANDS_LISTENER = new OnTelegramCommand();
|
public static final OnTelegramCommand COMMANDS_LISTENER = new OnTelegramCommand();
|
||||||
@SuppressWarnings("unused") public static final OnActivityRecord ACTIVITY_RECORDER = new OnActivityRecord();
|
// public static final OnActivityRecord ACTIVITY_RECORDER = new OnActivityRecord();
|
||||||
public static final OnUserSlashAction USER_SLASH_ACTION = new OnUserSlashAction();
|
public static final OnUserSlashAction USER_SLASH_ACTION = new OnUserSlashAction();
|
||||||
public static final OnUpdateTimestampOffsetLock UPDATE_TIMESTAMP_OFFSET_LOCK = new OnUpdateTimestampOffsetLock();
|
public static final OnUpdateTimestampOffsetLock UPDATE_TIMESTAMP_OFFSET_LOCK = new OnUpdateTimestampOffsetLock();
|
||||||
public static final OnInlineQueries INLINE_QUERY = new OnInlineQueries();
|
public static final OnInlineQueries INLINE_QUERY = new OnInlineQueries();
|
||||||
public static final OnCallMe CALL_ME = new OnCallMe();
|
public static final OnCallMe CALL_ME = new OnCallMe();
|
||||||
public static final OnEventHackHandle EVENT_HACK_HANDLE = new OnEventHackHandle();
|
public static final OnEventHackHandle EVENT_HACK_HANDLE = new OnEventHackHandle();
|
||||||
@SuppressWarnings("unused") static final OnKuohuanhuanNeedSleep KUOHUANHUAN_NEED_SLEEP = new OnKuohuanhuanNeedSleep();
|
// static final OnKuohuanhuanNeedSleep KUOHUANHUAN_NEED_SLEEP = new OnKuohuanhuanNeedSleep();
|
||||||
public static final OnUserRandoms USER_RANDOMS = new OnUserRandoms();
|
public static final OnUserRandoms USER_RANDOMS = new OnUserRandoms();
|
||||||
public static final OnCallMsgSend CALL_MSG_SEND = new OnCallMsgSend();
|
public static final OnCallMsgSend CALL_MSG_SEND = new OnCallMsgSend();
|
||||||
public static final OnMedicationNotifyApply MEDICATION_NOTIFY_APPLY = new OnMedicationNotifyApply();
|
public static final OnMedicationNotifyApply MEDICATION_NOTIFY_APPLY = new OnMedicationNotifyApply();
|
||||||
|
@ -7,6 +7,7 @@ import com.pengrad.telegrambot.model.Update;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public class OnActivityRecord extends EventListener {
|
public class OnActivityRecord extends EventListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -10,6 +10,7 @@ import java.util.Calendar;
|
|||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public class OnKuohuanhuanNeedSleep extends EventListener {
|
public class OnKuohuanhuanNeedSleep extends EventListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,7 +2,6 @@ package cc.sukazyo.cono.morny.bot.event;
|
|||||||
|
|
||||||
import cc.sukazyo.cono.morny.MornyCoeur;
|
import cc.sukazyo.cono.morny.MornyCoeur;
|
||||||
import cc.sukazyo.cono.morny.bot.api.EventListener;
|
import cc.sukazyo.cono.morny.bot.api.EventListener;
|
||||||
import cc.sukazyo.cono.morny.util.UniversalCommand;
|
|
||||||
import com.pengrad.telegrambot.model.Update;
|
import com.pengrad.telegrambot.model.Update;
|
||||||
import com.pengrad.telegrambot.request.SendMessage;
|
import com.pengrad.telegrambot.request.SendMessage;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -13,8 +12,8 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public class OnUserRandoms extends EventListener {
|
public class OnUserRandoms extends EventListener {
|
||||||
|
|
||||||
private static final Pattern USER_OR_CN_QUERY = Pattern.compile("(.+)还是(.+)");
|
private static final Pattern USER_OR_QUERY = Pattern.compile("(.+)(?:还是|or)(.+)");
|
||||||
private static final Pattern USER_OR_EN_QUERY = Pattern.compile("(.+)or(.+)");
|
private static final Pattern USER_IF_QUERY = Pattern.compile("(.+)[吗?|?]+$");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMessage (@NotNull Update update) {
|
public boolean onMessage (@NotNull Update update) {
|
||||||
@ -22,24 +21,14 @@ public class OnUserRandoms extends EventListener {
|
|||||||
if (update.message().text() == null) return false;
|
if (update.message().text() == null) return false;
|
||||||
if (!update.message().text().startsWith("/")) return false;
|
if (!update.message().text().startsWith("/")) return false;
|
||||||
|
|
||||||
final String[] preProcess = UniversalCommand.format(update.message().text());
|
final String query = update.message().text().substring(1);
|
||||||
if (preProcess.length > 1) return false;
|
|
||||||
final String query = preProcess[0];
|
|
||||||
|
|
||||||
// ----- START CODE BLOCK COMMENT -----
|
|
||||||
// 这里实现思路和代码优化有至少一半是 copilot 和 IDEA 提供的
|
|
||||||
// 实现思路都可以从人类手里抢一半贡献太恐怖了aba
|
|
||||||
String result = null;
|
String result = null;
|
||||||
final Matcher matcher;
|
Matcher matcher;
|
||||||
if (query.contains("还是")) {
|
if ((matcher = USER_OR_QUERY.matcher(query)).find()) {
|
||||||
matcher = USER_OR_CN_QUERY.matcher(query);
|
|
||||||
} else {
|
|
||||||
matcher = USER_OR_EN_QUERY.matcher(query);
|
|
||||||
}
|
|
||||||
if (matcher.find()) {
|
|
||||||
result = ThreadLocalRandom.current().nextBoolean() ? matcher.group(1) : matcher.group(2);
|
result = ThreadLocalRandom.current().nextBoolean() ? matcher.group(1) : matcher.group(2);
|
||||||
|
} else if ((matcher = USER_IF_QUERY.matcher(query)).matches()) {
|
||||||
|
result = (ThreadLocalRandom.current().nextBoolean()?"":"不") + matcher.group(1);
|
||||||
}
|
}
|
||||||
// ----- STOP CODE BLOCK COMMENT -----
|
|
||||||
|
|
||||||
if (result == null) return false;
|
if (result == null) return false;
|
||||||
MornyCoeur.extra().exec(new SendMessage(
|
MornyCoeur.extra().exec(new SendMessage(
|
||||||
|
Loading…
Reference in New Issue
Block a user