diff --git a/build.gradle b/build.gradle
index 4ec752e..1720565 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,14 +17,19 @@ repositories {
maven { name '-ws'; url 'https://mvn.sukazyo.cc' }
}
+String untitled (String lib, String upd = null) {
+ int majorCode = Integer.parseInt(project.libUntitledVersionMajor)
+ return "cc.sukazyo.untitled:$lib:[$majorCode${upd==null?"":".$upd"}, ${majorCode+1}["
+}
dependencies {
compileOnlyApi "com.github.spotbugs:spotbugs-annotations:${libSpotbugsVersion}"
- implementation "cc.sukazyo.untitled:util-string-commons:${libUntitledVersion}"
- implementation "cc.sukazyo.untitled:util-telegram-commons:${libUntitledVersion}"
- implementation "cc.sukazyo.untitled:util-telegram-api:${libUntitledVersion}"
-
+ implementation untitled("util-command-parser","1.0")
+ implementation untitled("util-string-commons", "1.0")
+ implementation untitled("util-telegram-api", "2.1")
+ implementation untitled("util-telegram-api-formatter", "3.3")
+ implementation untitled("util-telegram-commons", "1.0")
api "cc.sukazyo:messiva:${libMessivaVersion}"
implementation "com.github.pengrad:java-telegram-bot-api:${libJavaTelegramBotApiVersion}"
diff --git a/gradle.properties b/gradle.properties
index 91778ef..78cc80d 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,15 +1,15 @@
## Core
-VERSION = 0.4.3.6
+VERSION = 0.4.3.7
# dependencies
-libSpotbugsVersion = 4.5.2
+libSpotbugsVersion = 4.5.3
-libUntitledVersion = 1.+
+libUntitledVersionMajor = 1
libMessivaVersion = 0.1.0.1
-libJavaTelegramBotApiVersion = 5.5.0
+libJavaTelegramBotApiVersion = 5.6.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 9710257..91f2abf 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.3.6";
- public static final long COMPILE_TIMESTAMP = 1642747921571L;
+ public static final String VERSION = "0.4.3.7";
+ public static final long COMPILE_TIMESTAMP = 1642998030356L;
}
diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCallMe.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCallMe.java
index f5b80d9..ef4e85b 100644
--- a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCallMe.java
+++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCallMe.java
@@ -4,6 +4,7 @@ import cc.sukazyo.cono.morny.MornyCoeur;
import cc.sukazyo.cono.morny.MornyTrusted;
import cc.sukazyo.cono.morny.bot.api.EventListener;
import cc.sukazyo.cono.morny.data.TelegramStickers;
+import cc.sukazyo.untitled.telegram.api.formatting.TGToString;
import com.pengrad.telegrambot.model.Chat;
import com.pengrad.telegrambot.model.Update;
import com.pengrad.telegrambot.model.request.ParseMode;
@@ -13,8 +14,6 @@ import com.pengrad.telegrambot.request.SendSticker;
import javax.annotation.Nonnull;
-import static cc.sukazyo.untitled.util.telegram.formatting.MsgEscape.escapeHtml;
-
/**
* 通过 bot 呼叫主人的事件监听管理类
* @since 0.4.2.1
@@ -74,11 +73,8 @@ public class OnCallMe extends EventListener {
ME, String.format(
"""
request STEAM LIBRARY
- from %s""",
- event.message().from().id(),
- escapeHtml(
- event.message().from().firstName() + " " + event.message().from().lastName()
- )
+ from %s""",
+ TGToString.as(event.message().from()).fullnameRefHtml()
)
).parseMode(ParseMode.HTML));
}
@@ -94,11 +90,8 @@ public class OnCallMe extends EventListener {
ME, String.format(
"""
request Hana Paresu
- from %s""",
- event.message().from().id(),
- escapeHtml(
- event.message().from().firstName() + " " + event.message().from().lastName()
- )
+ from %s""",
+ TGToString.as(event.message().from()).fullnameRefHtml()
)
).parseMode(ParseMode.HTML));
}
@@ -122,11 +115,8 @@ public class OnCallMe extends EventListener {
ME, String.format(
"""
request [???]
- from %s""",
- event.message().from().id(),
- escapeHtml(
- event.message().from().firstName() + " " + event.message().from().lastName()
- )
+ from %s""",
+ TGToString.as(event.message().from()).fullnameRefHtml()
)
).parseMode(ParseMode.HTML));
MornyCoeur.extra().exec(new ForwardMessage(
diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCommandExecute.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCommandExecute.java
index f4febb9..6196de1 100644
--- a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCommandExecute.java
+++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnCommandExecute.java
@@ -10,6 +10,7 @@ import cc.sukazyo.cono.morny.bot.event.on_commands.Ip186Query;
import cc.sukazyo.cono.morny.bot.event.on_commands.Nbnhhsh;
import cc.sukazyo.cono.morny.data.MornyJrrp;
import cc.sukazyo.cono.morny.data.TelegramStickers;
+import cc.sukazyo.untitled.telegram.api.formatting.TGToString;
import cc.sukazyo.untitled.util.telegram.object.InputCommand;
import com.pengrad.telegrambot.model.Update;
@@ -112,7 +113,7 @@ public class OnCommandExecute extends EventListener {
TelegramStickers.ID_EXIT
).replyToMessageId(event.message().messageId())
);
- logger.info("Morny exited by user @" + event.message().from().username());
+ logger.info("Morny exited by user " + TGToString.as(event.message().from()).toStringLogTag());
System.exit(0);
} else {
MornyCoeur.extra().exec(new SendSticker(
@@ -120,7 +121,7 @@ public class OnCommandExecute extends EventListener {
TelegramStickers.ID_403
).replyToMessageId(event.message().messageId())
);
- logger.info("403 exited tag from user @" + event.message().from().username());
+ logger.info("403 exited tag from user " + TGToString.as(event.message().from()).toStringLogTag());
}
}
@@ -200,9 +201,8 @@ public class OnCommandExecute extends EventListener {
MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
String.format(
- "%s 在(utc的)今天的运气指数是———— %.2f%%
%s",
- event.message().from().id(),
- escapeHtml(event.message().from().firstName()),
+ "%s 在(utc的)今天的运气指数是———— %.2f%%
%s",
+ TGToString.as(event.message().from()).fullnameRefHtml(),
jrrp, escapeHtml(endChar)
)
).replyToMessageId(event.message().messageId()).parseMode(ParseMode.HTML));
@@ -213,7 +213,7 @@ public class OnCommandExecute extends EventListener {
*/
private void onSaveDataExec (Update event) {
if (MornyCoeur.trustedInstance().isTrusted(event.message().from().id())) {
- logger.info(String.format("called save from command by @%s.", event.message().from().username()));
+ logger.info("called save from command by " + TGToString.as(event.message().from()).toStringLogTag());
MornyCoeur.callSaveData();
MornyCoeur.extra().exec(new SendSticker(
event.message().chat().id(),
@@ -226,7 +226,7 @@ public class OnCommandExecute extends EventListener {
TelegramStickers.ID_403
).replyToMessageId(event.message().messageId())
);
- logger.info("403 call save tag from user @" + event.message().from().username());
+ logger.info("403 call save tag from user " + TGToString.as(event.message().from()).toStringLogTag());
}
}
diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnUserSlashAction.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnUserSlashAction.java
index 317ccce..5c4cf79 100644
--- a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnUserSlashAction.java
+++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnUserSlashAction.java
@@ -2,6 +2,7 @@ package cc.sukazyo.cono.morny.bot.event;
import cc.sukazyo.cono.morny.MornyCoeur;
import cc.sukazyo.cono.morny.bot.api.EventListener;
+import cc.sukazyo.untitled.telegram.api.formatting.TGToString;
import cc.sukazyo.untitled.util.command.CommonCommand;
import cc.sukazyo.untitled.util.string.StringArrays;
@@ -22,21 +23,21 @@ public class OnUserSlashAction extends EventListener {
final String text = event.message().text();
if (text == null) return false;
- // Due to @Lapis_Apple, we stopped slash action function at .DP7 groups.
- // It may be enabled after some of updates when the function will not be conflicted to other bots.
- // if (event.message().chat().id() == ) return false;
- if (event.message().chat().title() != null && event.message().chat().title().contains(".DP7")) {
- logger.info(String.format("""
- Chat slash action ignored due to keyword \".DP7\".
- - %s
- - [%d]""",
- event.message().chat().title(),
- event.message().chat().id()
- ));
- return false;
- }
-
if (text.startsWith("/")) {
+
+ /// Due to @Lapis_Apple, we stopped slash action function at .DP7 groups.
+ /// It may be enabled after some updates when the function will not be conflicted to other bots.
+ // if (event.message().chat().id() == ) return false;
+ if (event.message().chat().title() != null && event.message().chat().title().contains(".DP7")) {
+ logger.info(String.format("""
+ Chat slash action ignored due to the following keyword.
+ - %s
+ - ".DP7\"""",
+ TGToString.as(event.message().chat()).toStringFullNameId()
+ ));
+ return false;
+ }
+
int prefixLength = 1;
boolean useVerbSuffix = true;
boolean useObjectPrefix = true;
@@ -66,10 +67,12 @@ public class OnUserSlashAction extends EventListener {
MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
String.format(
- "%s %s%s %s%s%s",
- origin.id(), escapeHtml(origin.firstName()),
+ "%s %s%s %s%s%s",
+ TGToString.as(origin).firstnameRefHtml(),
verb, escapeHtml((useVerbSuffix?"了":"")),
- target.id(), escapeHtml((origin==target ? "自己" : target.firstName())),
+ origin==target ?
+ "自己" :
+ TGToString.as(target).firstnameRefHtml(),
escapeHtml((hasObject ? (useObjectPrefix ?" 的": " ") : "")),
escapeHtml((hasObject ? object : ""))
)