mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-22 11:14:55 +08:00
parent
b252b3de51
commit
b5941494f6
@ -1,6 +1,6 @@
|
||||
## Core
|
||||
|
||||
VERSION = 0.6.3.1
|
||||
VERSION = 0.6.3.2
|
||||
|
||||
# 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.6.3.0";
|
||||
public static final long COMPILE_TIMESTAMP = 1651804975121L;
|
||||
public static final String VERSION = "0.6.3.2";
|
||||
public static final long COMPILE_TIMESTAMP = 1651806802187L;
|
||||
}
|
||||
|
@ -2,12 +2,13 @@ package cc.sukazyo.cono.morny.bot.event;
|
||||
|
||||
import cc.sukazyo.cono.morny.MornyCoeur;
|
||||
import cc.sukazyo.cono.morny.bot.api.EventListener;
|
||||
import cc.sukazyo.cono.morny.util.tgapi.TGToStringFromMessage;
|
||||
import cc.sukazyo.untitled.telegram.api.formatting.TGToString;
|
||||
import cc.sukazyo.untitled.util.command.CommonCommand;
|
||||
import cc.sukazyo.untitled.util.string.StringArrays;
|
||||
|
||||
import com.pengrad.telegrambot.model.Message;
|
||||
import com.pengrad.telegrambot.model.Update;
|
||||
import com.pengrad.telegrambot.model.User;
|
||||
import com.pengrad.telegrambot.model.request.ParseMode;
|
||||
import com.pengrad.telegrambot.request.SendMessage;
|
||||
|
||||
@ -55,22 +56,22 @@ public class OnUserSlashAction extends EventListener {
|
||||
hasObject ?
|
||||
StringArrays.connectStringArray(action, " ", isHardParse?2:1, action.length-1) :
|
||||
"";
|
||||
final User origin = event.message().from();
|
||||
final User target = (event.message().replyToMessage() == null ? (
|
||||
final Message origin = event.message();
|
||||
final Message target = (event.message().replyToMessage() == null ? (
|
||||
origin
|
||||
): (
|
||||
event.message().replyToMessage().from()
|
||||
event.message().replyToMessage()
|
||||
));
|
||||
|
||||
MornyCoeur.extra().exec(new SendMessage(
|
||||
event.message().chat().id(),
|
||||
String.format(
|
||||
"%s %s%s %s %s!",
|
||||
TGToString.as(origin).firstnameRefHtml(),
|
||||
TGToStringFromMessage.as(origin).getSenderFirstNameRefHtml(),
|
||||
escapeHtml(verb), escapeHtml((hasObject?"":"了")),
|
||||
origin==target ?
|
||||
"<a href='tg://user?id="+target.id()+"'>自己</a>" :
|
||||
TGToString.as(target).firstnameRefHtml(),
|
||||
"<a href='tg://user?id="+TGToStringFromMessage.as(target).getSenderId()+"'>自己</a>" :
|
||||
TGToStringFromMessage.as(target).getSenderFirstNameRefHtml(),
|
||||
escapeHtml(hasObject ? object+" " : "")
|
||||
)
|
||||
).parseMode(ParseMode.HTML).replyToMessageId(event.message().messageId()));
|
||||
|
@ -0,0 +1,30 @@
|
||||
package cc.sukazyo.cono.morny.util.tgapi;
|
||||
|
||||
import cc.sukazyo.untitled.telegram.api.formatting.TGToString;
|
||||
import cc.sukazyo.untitled.util.telegram.formatting.MsgEscape;
|
||||
import com.pengrad.telegrambot.model.Message;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TGToStringFromMessage extends TGToString {
|
||||
|
||||
@Nonnull
|
||||
private final Message message;
|
||||
|
||||
public TGToStringFromMessage (@Nonnull Message message) { this.message = message; }
|
||||
public static TGToStringFromMessage as (@Nonnull Message message) { return new TGToStringFromMessage(message); }
|
||||
|
||||
@Nonnull
|
||||
public String getSenderFirstNameRefHtml () {
|
||||
return message.senderChat()==null ? TGToString.as(message.from()).firstnameRefHtml() : String.format(
|
||||
"<a href='tg://user?id=%d'>%s</a>",
|
||||
message.senderChat().id(),
|
||||
MsgEscape.escapeHtml(message.senderChat().title())
|
||||
);
|
||||
}
|
||||
|
||||
public long getSenderId () {
|
||||
return message.senderChat()==null ? message.from().id() : message.senderChat().id();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user