From dc332de50c8735b1a5a4e7e73d85ee8f890c9b7d Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Fri, 10 Dec 2021 01:08:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=87=E6=97=B6=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8A=91=E5=88=B6=E7=9A=84bug=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20tgapi-5.4.0=20=E6=96=B0=E4=BA=8B=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E8=AE=A2=20javadoc=EF=BC=8C=E4=BF=AE=E8=AE=A2?= =?UTF-8?q?=E4=B8=80=E4=B8=AAlog=E7=9A=84=E4=BF=A1=E6=81=AF=EF=BC=8Cgradle?= =?UTF-8?q?.properties?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 项目的版本数据现在由 gradle.properties 管理 - 修复 outdated-block 的实现中单位计算出现错误导致的全部消息都会被阻止的问题 - EventAPI 添加 ChatJoinRequest 事件支持 - 更改 TrackerDataManager 守护线程的关机清理的消息和优先级 - 修订 MornyCoeur 类 javadoc 换行,删除 ServerMain javadoc无用信息 --- build.gradle | 10 +++++----- gradle.properties | 11 +++++++++++ .../sukazyo/cono/morny/GradleProjectConfigures.java | 4 ++-- src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java | 1 - src/main/java/cc/sukazyo/cono/morny/ServerMain.java | 7 ------- .../cc/sukazyo/cono/morny/bot/api/EventListener.java | 4 ++++ .../cono/morny/bot/api/EventListenerManager.java | 4 ++++ .../java/cc/sukazyo/cono/morny/bot/api/OnUpdate.java | 3 +++ .../morny/bot/event/OnUpdateTimestampOffsetLock.java | 2 +- .../cono/morny/data/tracker/TrackerDataManager.java | 2 +- 10 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 gradle.properties diff --git a/build.gradle b/build.gradle index 50aeb34..7c3c566 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ plugins { } group 'cc.sukazyo' -version '0.4.0.1' +version VERSION project.ext.archiveBaseName = 'Coeur_Morny_Cono' project.ext.artifactId = 'morny-coeur' mainClassName = 'cc.sukazyo.cono.morny.ServerMain' @@ -18,12 +18,12 @@ repositories { dependencies { - compileOnlyApi "com.github.spotbugs:spotbugs-annotations:4.5.0" + compileOnlyApi "com.github.spotbugs:spotbugs-annotations:${libSpotbugsVersion}" - implementation 'com.github.pengrad:java-telegram-bot-api:5.4.0' + implementation "com.github.pengrad:java-telegram-bot-api:${libJavaTelegramBotApiVersion}" - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' + testImplementation "org.junit.jupiter:junit-jupiter-api:${libJunitVersion}" + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${libJunitVersion}" } diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..7d6499a --- /dev/null +++ b/gradle.properties @@ -0,0 +1,11 @@ +## Core + +VERSION = 0.4.1.0 + +# dependencies + +libSpotbugsVersion = 4.5.0 + +libJavaTelegramBotApiVersion = 5.5.0 + +libJunitVersion = 5.8.2 diff --git a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java index da12eb9..5b74266 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.4.0.1"; - public static final long COMPILE_TIMESTAMP = 1638938903400L; + public static final String VERSION = "0.4.1.0"; + public static final long COMPILE_TIMESTAMP = 1639069681128L; } diff --git a/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java b/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java index 4dc90bf..e611353 100644 --- a/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java +++ b/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java @@ -13,7 +13,6 @@ import static cc.sukazyo.cono.morny.Logger.logger; /** * Morny Cono 核心
- *
* - 的程序化入口类,保管着 morny 的核心属性
*/ public class MornyCoeur { diff --git a/src/main/java/cc/sukazyo/cono/morny/ServerMain.java b/src/main/java/cc/sukazyo/cono/morny/ServerMain.java index 49074d0..f18487d 100644 --- a/src/main/java/cc/sukazyo/cono/morny/ServerMain.java +++ b/src/main/java/cc/sukazyo/cono/morny/ServerMain.java @@ -13,13 +13,6 @@ import static cc.sukazyo.cono.morny.Logger.logger; * 程序启动入口
*
* 会处理程序传入的参数和选项等数据,并执行对应的启动方式
- *
- * - 第一个参数({@code args[0]})必序传递,值为 telegram-bot 的 api-token
- * - 第二个参数可选 {@code --no-hello} 和 {@code --only-hello}, - * 前者表示不输出{@link MornyHello#MORNY_PREVIEW_IMAGE_ASCII 欢迎标语}, - * 后者表示只输出{@link MornyHello#MORNY_PREVIEW_IMAGE_ASCII 欢迎标语}而不运行程序逻辑
- *
- * 或者,在第一个参数处使用 {@code --version} 来输出当前程序的版本信息 * * @since 0.4.0.0 */ diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/api/EventListener.java b/src/main/java/cc/sukazyo/cono/morny/bot/api/EventListener.java index 73e4c1a..a7c8c5e 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/api/EventListener.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/api/EventListener.java @@ -59,4 +59,8 @@ public abstract class EventListener { return false; } + public boolean onChatJoinRequest (@Nonnull Update update) { + return false; + } + } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/api/EventListenerManager.java b/src/main/java/cc/sukazyo/cono/morny/bot/api/EventListenerManager.java index 5ac91a6..483b492 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/api/EventListenerManager.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/api/EventListenerManager.java @@ -93,4 +93,8 @@ public class EventListenerManager { new EventPublisher(update, x -> x.onChatMemberUpdated(update)).start(); } + public static void publishChatJoinRequestEvent (@Nonnull Update update) { + new EventPublisher(update, x -> x.onChatJoinRequest(update)).start(); + } + } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/api/OnUpdate.java b/src/main/java/cc/sukazyo/cono/morny/bot/api/OnUpdate.java index 8427283..e03653b 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/api/OnUpdate.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/api/OnUpdate.java @@ -49,6 +49,9 @@ public class OnUpdate { if (update.chatMember() != null) { EventListenerManager.publishChatMemberUpdatedEvent(update); } + if (update.chatJoinRequest() != null) { + EventListenerManager.publishChatJoinRequestEvent(update); + } } return UpdatesListener.CONFIRMED_UPDATES_ALL; } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnUpdateTimestampOffsetLock.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnUpdateTimestampOffsetLock.java index 2ad2fd4..7130277 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnUpdateTimestampOffsetLock.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnUpdateTimestampOffsetLock.java @@ -9,7 +9,7 @@ public class OnUpdateTimestampOffsetLock extends EventListener { @Override public boolean onMessage (@NotNull Update update) { - return update.message().date() < MornyCoeur.latestEventTimestamp*1000; + return update.message().date() < MornyCoeur.latestEventTimestamp/1000; } } diff --git a/src/main/java/cc/sukazyo/cono/morny/data/tracker/TrackerDataManager.java b/src/main/java/cc/sukazyo/cono/morny/data/tracker/TrackerDataManager.java index 1695a24..048df3c 100644 --- a/src/main/java/cc/sukazyo/cono/morny/data/tracker/TrackerDataManager.java +++ b/src/main/java/cc/sukazyo/cono/morny/data/tracker/TrackerDataManager.java @@ -40,7 +40,7 @@ public class TrackerDataManager { } if (interrupted()) { postProcess = true; - logger.warn("last tracker write in this processor!"); + logger.info("CALLED TO EXIT! writing cache."); } if (record.size() != 0) { logger.info("start writing tracker data.");