mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-22 11:14:55 +08:00
为 @kuohuanhuan 添加睡觉禁止发言的功能
This commit is contained in:
parent
7bbe75a522
commit
b9aa9de57a
@ -1,6 +1,6 @@
|
||||
## Core
|
||||
|
||||
VERSION = 0.5.2.0
|
||||
VERSION = 0.5.2.1
|
||||
|
||||
# dependencies
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user