mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-22 11:14:55 +08:00
项目 TG 对象转字符串使用 untitled 库,更新 untitled 类库导入方式,日常依赖更新
- groovy:untitled(String,String) - dependencies - untitled:util-telegram-api-formatter + - spotbugs 4.5.2 -> 4.5.3 - javaTelegramApi 5.5.0 -> 5.6.0
This commit is contained in:
parent
8f2c63e300
commit
3762261cff
13
build.gradle
13
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}"
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 <b>STEAM LIBRARY</b>
|
||||
from <a href="tg://user?id=%d">%s</a>""",
|
||||
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 <b>Hana Paresu</b>
|
||||
from <a href="tg://user?id=%d">%s</a>""",
|
||||
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 <u>[???]</u>
|
||||
from <a href="tg://user?id=%d">%s</a>""",
|
||||
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(
|
||||
|
@ -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(
|
||||
"<a href='tg://user?id=%d'>%s</a> 在(utc的)今天的运气指数是———— <code>%.2f%%</code> %s",
|
||||
event.message().from().id(),
|
||||
escapeHtml(event.message().from().firstName()),
|
||||
"%s 在(utc的)今天的运气指数是———— <code>%.2f%%</code> %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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
"<a href='tg://user?id=%d'>%s</a> %s%s <a href='tg://user?id=%d'>%s</a>%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 ?
|
||||
"<a href='tg://user?id="+target.id()+"'>自己</a>" :
|
||||
TGToString.as(target).firstnameRefHtml(),
|
||||
escapeHtml((hasObject ? (useObjectPrefix ?" 的": " ") : "")),
|
||||
escapeHtml((hasObject ? object : ""))
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user