From b9aa9de57a42084b6a0d0271d54311d3b61c3b04 Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Sun, 13 Mar 2022 19:21:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=20@kuohuanhuan=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=9D=A1=E8=A7=89=E7=A6=81=E6=AD=A2=E5=8F=91=E8=A8=80=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../cono/morny/GradleProjectConfigures.java | 4 +-- .../cono/morny/bot/event/EventListeners.java | 2 ++ .../bot/event/OnKuohuanhuanNeedSleep.java | 32 +++++++++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 src/main/java/cc/sukazyo/cono/morny/bot/event/OnKuohuanhuanNeedSleep.java diff --git a/gradle.properties b/gradle.properties index a1972de..5667829 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ ## Core -VERSION = 0.5.2.0 +VERSION = 0.5.2.1 # dependencies diff --git a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java index 6718b5e..8d7906c 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.2.0"; - public static final long COMPILE_TIMESTAMP = 1646742061976L; + public static final String VERSION = "0.5.2.1"; + public static final long COMPILE_TIMESTAMP = 1647170439025L; } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/EventListeners.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/EventListeners.java index 3920a57..4eca5a5 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/event/EventListeners.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/EventListeners.java @@ -11,11 +11,13 @@ public class EventListeners { public static final OnInlineQueries INLINE_QUERY = new OnInlineQueries(); public static final OnCallMe CALL_ME = new OnCallMe(); public static final OnEventHackHandle EVENT_HACK_HANDLE = new OnEventHackHandle(); + public static final OnKuohuanhuanNeedSleep KUOHUANHUAN_NEED_SLEEP = new OnKuohuanhuanNeedSleep(); public static void registerAllListeners () { EventListenerManager.addListener( ACTIVITY_RECORDER, UPDATE_TIMESTAMP_OFFSET_LOCK, + KUOHUANHUAN_NEED_SLEEP, COMMANDS_LISTENER, USER_SLASH_ACTION, INLINE_QUERY, diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnKuohuanhuanNeedSleep.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnKuohuanhuanNeedSleep.java new file mode 100644 index 0000000..3c7101c --- /dev/null +++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnKuohuanhuanNeedSleep.java @@ -0,0 +1,32 @@ +package cc.sukazyo.cono.morny.bot.event; + +import cc.sukazyo.cono.morny.MornyCoeur; +import cc.sukazyo.cono.morny.bot.api.EventListener; +import com.pengrad.telegrambot.model.Update; +import com.pengrad.telegrambot.request.DeleteMessage; + +import javax.annotation.Nonnull; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Locale; + +public class OnKuohuanhuanNeedSleep extends EventListener { + + @Override + public boolean onMessage (@Nonnull Update update) { + if ( + update.message().from().id() == 786563752L && ( + new GregorianCalendar(Locale.TAIWAN).get(Calendar.HOUR_OF_DAY) >= 23 || + new GregorianCalendar(Locale.TAIWAN).get(Calendar.HOUR_OF_DAY) < 5 + ) + ) { + MornyCoeur.extra().exec( + new DeleteMessage(update.message().chat().id(), + update.message().messageId()) + ); + return true; + } + return false; + } + +}