mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-23 03:27:39 +08:00
斜线响应使其基本符合 t.me/hasutestbot 标准 (#26) 修复版本号改错
This commit is contained in:
parent
b9aa9de57a
commit
79e61e28a2
@ -1,6 +1,6 @@
|
|||||||
## Core
|
## Core
|
||||||
|
|
||||||
VERSION = 0.5.2.1
|
VERSION = 0.6.0.2
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
|
|
||||||
|
@ -4,6 +4,6 @@ package cc.sukazyo.cono.morny;
|
|||||||
* the final field that will be updated by gradle automatically.
|
* the final field that will be updated by gradle automatically.
|
||||||
*/
|
*/
|
||||||
public class GradleProjectConfigures {
|
public class GradleProjectConfigures {
|
||||||
public static final String VERSION = "0.5.2.1";
|
public static final String VERSION = "0.6.0.2";
|
||||||
public static final long COMPILE_TIMESTAMP = 1647170439025L;
|
public static final long COMPILE_TIMESTAMP = 1647237887029L;
|
||||||
}
|
}
|
||||||
|
@ -38,25 +38,23 @@ public class OnUserSlashAction extends EventListener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int prefixLength = 1;
|
final String[] action = CommonCommand.format(text);
|
||||||
boolean useVerbSuffix = true;
|
action[0] = action[0].substring(1);
|
||||||
boolean useObjectPrefix = true;
|
|
||||||
if (text.startsWith("//#") || text.startsWith("///")) {
|
if (action[0].matches("^[a-zA-Z_]+$")) {
|
||||||
useVerbSuffix = false;
|
return false; // 忽略掉 Telegram 命令格式的输入
|
||||||
useObjectPrefix = false;
|
} else if (action[0].contains("/")) {
|
||||||
prefixLength = 3;
|
return false; // 忽略掉疑似目录格式的输入
|
||||||
} else if (text.startsWith("/#")) {
|
|
||||||
useObjectPrefix = false;
|
|
||||||
prefixLength = 2;
|
|
||||||
} else if (text.startsWith("//")) {
|
|
||||||
useVerbSuffix = false;
|
|
||||||
prefixLength = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final String[] action = CommonCommand.format(text.substring(prefixLength));
|
final boolean isHardParse = "".equals(action[0]);
|
||||||
final String verb = action[0];
|
/* 忽略空数据 */ if (isHardParse && action.length < 2) { return false; }
|
||||||
final boolean hasObject = action.length != 1;
|
final String verb = isHardParse ? action[1] : action[0];
|
||||||
final String object = StringArrays.connectStringArray(action, " ", 1, action.length-1);
|
final boolean hasObject = action.length != (isHardParse?2:1);
|
||||||
|
final String object =
|
||||||
|
hasObject ?
|
||||||
|
StringArrays.connectStringArray(action, " ", isHardParse?2:1, action.length-1) :
|
||||||
|
"";
|
||||||
final User origin = event.message().from();
|
final User origin = event.message().from();
|
||||||
final User target = (event.message().replyToMessage() == null ? (
|
final User target = (event.message().replyToMessage() == null ? (
|
||||||
origin
|
origin
|
||||||
@ -67,16 +65,15 @@ public class OnUserSlashAction extends EventListener {
|
|||||||
MornyCoeur.extra().exec(new SendMessage(
|
MornyCoeur.extra().exec(new SendMessage(
|
||||||
event.message().chat().id(),
|
event.message().chat().id(),
|
||||||
String.format(
|
String.format(
|
||||||
"%s %s%s %s%s%s",
|
"%s %s%s %s %s!",
|
||||||
TGToString.as(origin).firstnameRefHtml(),
|
TGToString.as(origin).firstnameRefHtml(),
|
||||||
verb, escapeHtml((useVerbSuffix?"了":"")),
|
escapeHtml(verb), escapeHtml((hasObject?"":"了")),
|
||||||
origin==target ?
|
origin==target ?
|
||||||
"<a href='tg://user?id="+target.id()+"'>自己</a>" :
|
"<a href='tg://user?id="+target.id()+"'>自己</a>" :
|
||||||
TGToString.as(target).firstnameRefHtml(),
|
TGToString.as(target).firstnameRefHtml(),
|
||||||
escapeHtml((hasObject ? (useObjectPrefix ?" 的": " ") : "")),
|
escapeHtml(hasObject ? object+" " : "")
|
||||||
escapeHtml((hasObject ? object : ""))
|
|
||||||
)
|
)
|
||||||
).parseMode(ParseMode.HTML));
|
).parseMode(ParseMode.HTML).replyToMessageId(event.message().messageId()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user