mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-22 19:24:53 +08:00
添加事件劫持功能的命令端口,文本更改,添加贴纸管理类
- 添加事件劫持与返回命令的事件请求命令 - 添加贴纸管理类集中存放贴纸 id - 修改 runtime 方法中的 memory 字段名为 "vm memory" - 为 runtime 方法, OnInlineQuery 添加 @since 标签
This commit is contained in:
parent
a2011e486d
commit
ff428f76b2
@ -1,6 +1,6 @@
|
|||||||
## Core
|
## Core
|
||||||
|
|
||||||
VERSION = 0.4.1.3
|
VERSION = 0.4.2.0
|
||||||
|
|
||||||
# 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.4.1.3";
|
public static final String VERSION = "0.4.2.0";
|
||||||
public static final long COMPILE_TIMESTAMP = 1639476313268L;
|
public static final long COMPILE_TIMESTAMP = 1639492714364L;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,9 @@ import cc.sukazyo.cono.morny.MornySystem;
|
|||||||
import cc.sukazyo.cono.morny.MornyTrusted;
|
import cc.sukazyo.cono.morny.MornyTrusted;
|
||||||
import cc.sukazyo.cono.morny.bot.api.EventListener;
|
import cc.sukazyo.cono.morny.bot.api.EventListener;
|
||||||
import cc.sukazyo.cono.morny.bot.api.InputCommand;
|
import cc.sukazyo.cono.morny.bot.api.InputCommand;
|
||||||
|
import cc.sukazyo.cono.morny.bot.event.on_commands.EventHack;
|
||||||
import cc.sukazyo.cono.morny.bot.event.on_commands.GetUsernameAndId;
|
import cc.sukazyo.cono.morny.bot.event.on_commands.GetUsernameAndId;
|
||||||
|
import cc.sukazyo.cono.morny.data.TelegramStickers;
|
||||||
import cc.sukazyo.cono.morny.util.CommonFormatUtils;
|
import cc.sukazyo.cono.morny.util.CommonFormatUtils;
|
||||||
import com.pengrad.telegrambot.model.Update;
|
import com.pengrad.telegrambot.model.Update;
|
||||||
import com.pengrad.telegrambot.model.request.ParseMode;
|
import com.pengrad.telegrambot.model.request.ParseMode;
|
||||||
@ -19,12 +21,6 @@ import static cc.sukazyo.cono.morny.Log.logger;
|
|||||||
|
|
||||||
public class OnCommandExecute extends EventListener {
|
public class OnCommandExecute extends EventListener {
|
||||||
|
|
||||||
private static final String ONLINE_STATUS_RETURN_STICKER_ID = "CAACAgEAAx0CW-CvvgAC5eBhhhODGRuu0pxKLwoQ3yMsowjviAACcycAAnj8xgVVU666si1utiIE";
|
|
||||||
private static final String HELLO_STICKER_ID = "CAACAgEAAxkBAAMnYYYWKNXO4ibo9dlsmDctHhhV6fIAAqooAAJ4_MYFJJhrHS74xUAiBA";
|
|
||||||
private static final String EXIT_STICKER_ID = "CAACAgEAAxkBAAMoYYYWt8UjvP0N405SAyvg2SQZmokAAkMiAAJ4_MYFw6yZLu06b-MiBA";
|
|
||||||
private static final String EXIT_403_STICKER_ID = "CAACAgEAAxkBAAMqYYYa_7hpXH6hMOYMX4Nh8AVYd74AAnQnAAJ4_MYFRdmmsQKLDZgiBA";
|
|
||||||
private static final String NON_COMMAND_QUESTION_STICKER_ID = "CAACAgEAAx0CSQh32gABA966YbRJpbmi2lCHINBDuo1DknSTsbsAAqUoAAJ4_MYFUa8SIaZriAojBA";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMessage (@Nonnull Update event) {
|
public boolean onMessage (@Nonnull Update event) {
|
||||||
if (event.message().text() == null) {
|
if (event.message().text() == null) {
|
||||||
@ -38,6 +34,9 @@ public class OnCommandExecute extends EventListener {
|
|||||||
case "/user":
|
case "/user":
|
||||||
GetUsernameAndId.exec(command.getArgs(), event);
|
GetUsernameAndId.exec(command.getArgs(), event);
|
||||||
break;
|
break;
|
||||||
|
case "/event_hack":
|
||||||
|
EventHack.exec(event, command);
|
||||||
|
break;
|
||||||
case "/o":
|
case "/o":
|
||||||
onCommandOnExec(event);
|
onCommandOnExec(event);
|
||||||
break;
|
break;
|
||||||
@ -65,7 +64,7 @@ public class OnCommandExecute extends EventListener {
|
|||||||
else { // 无法解析的显式命令格式,报错找不到命令
|
else { // 无法解析的显式命令格式,报错找不到命令
|
||||||
MornyCoeur.getAccount().execute(new SendSticker(
|
MornyCoeur.getAccount().execute(new SendSticker(
|
||||||
event.message().chat().id(),
|
event.message().chat().id(),
|
||||||
NON_COMMAND_QUESTION_STICKER_ID
|
TelegramStickers.ID_404
|
||||||
).replyToMessageId(event.message().messageId())
|
).replyToMessageId(event.message().messageId())
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
@ -75,7 +74,7 @@ public class OnCommandExecute extends EventListener {
|
|||||||
private void onCommandOnExec (@Nonnull Update event) {
|
private void onCommandOnExec (@Nonnull Update event) {
|
||||||
MornyCoeur.getAccount().execute(new SendSticker(
|
MornyCoeur.getAccount().execute(new SendSticker(
|
||||||
event.message().chat().id(),
|
event.message().chat().id(),
|
||||||
ONLINE_STATUS_RETURN_STICKER_ID
|
TelegramStickers.ID_ONLINE_STATUS_RETURN
|
||||||
).replyToMessageId(event.message().messageId())
|
).replyToMessageId(event.message().messageId())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -83,7 +82,7 @@ public class OnCommandExecute extends EventListener {
|
|||||||
private void onCommandHelloExec (@Nonnull Update event) {
|
private void onCommandHelloExec (@Nonnull Update event) {
|
||||||
MornyCoeur.getAccount().execute(new SendSticker(
|
MornyCoeur.getAccount().execute(new SendSticker(
|
||||||
event.message().chat().id(),
|
event.message().chat().id(),
|
||||||
HELLO_STICKER_ID
|
TelegramStickers.ID_HELLO
|
||||||
).replyToMessageId(event.message().messageId())
|
).replyToMessageId(event.message().messageId())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -92,7 +91,7 @@ public class OnCommandExecute extends EventListener {
|
|||||||
if (MornyTrusted.isTrusted(event.message().from().id())) {
|
if (MornyTrusted.isTrusted(event.message().from().id())) {
|
||||||
MornyCoeur.getAccount().execute(new SendSticker(
|
MornyCoeur.getAccount().execute(new SendSticker(
|
||||||
event.message().chat().id(),
|
event.message().chat().id(),
|
||||||
EXIT_STICKER_ID
|
TelegramStickers.ID_EXIT
|
||||||
).replyToMessageId(event.message().messageId())
|
).replyToMessageId(event.message().messageId())
|
||||||
);
|
);
|
||||||
logger.info("Morny exited by user @" + event.message().from().username());
|
logger.info("Morny exited by user @" + event.message().from().username());
|
||||||
@ -100,7 +99,7 @@ public class OnCommandExecute extends EventListener {
|
|||||||
} else {
|
} else {
|
||||||
MornyCoeur.getAccount().execute(new SendSticker(
|
MornyCoeur.getAccount().execute(new SendSticker(
|
||||||
event.message().chat().id(),
|
event.message().chat().id(),
|
||||||
EXIT_403_STICKER_ID
|
TelegramStickers.ID_403
|
||||||
).replyToMessageId(event.message().messageId())
|
).replyToMessageId(event.message().messageId())
|
||||||
);
|
);
|
||||||
logger.info("403 exited tag from user @" + event.message().from().username());
|
logger.info("403 exited tag from user @" + event.message().from().username());
|
||||||
@ -126,6 +125,9 @@ public class OnCommandExecute extends EventListener {
|
|||||||
).replyToMessageId(event.message().messageId()).parseMode(ParseMode.HTML));
|
).replyToMessageId(event.message().messageId()).parseMode(ParseMode.HTML));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.4.1.2
|
||||||
|
*/
|
||||||
private void onCommandRuntimeExec (@Nonnull Update event) {
|
private void onCommandRuntimeExec (@Nonnull Update event) {
|
||||||
MornyCoeur.getAccount().execute(new SendMessage(
|
MornyCoeur.getAccount().execute(new SendMessage(
|
||||||
event.message().chat().id(),
|
event.message().chat().id(),
|
||||||
@ -137,7 +139,7 @@ public class OnCommandExecute extends EventListener {
|
|||||||
java runtime:
|
java runtime:
|
||||||
- <code>%s</code>
|
- <code>%s</code>
|
||||||
- <code>%s</code>
|
- <code>%s</code>
|
||||||
memory:
|
vm memory:
|
||||||
- <code>%d</code> / <code>%d</code> MB
|
- <code>%d</code> / <code>%d</code> MB
|
||||||
morny version:
|
morny version:
|
||||||
- <code>%s</code>
|
- <code>%s</code>
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package cc.sukazyo.cono.morny.bot.event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.4.2.0
|
||||||
|
*/
|
||||||
|
public class OnEventHackHandle {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.4.2.0
|
||||||
|
*/
|
||||||
|
public enum HackType {
|
||||||
|
USER, GROUP, ANY
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.4.2.0
|
||||||
|
*/
|
||||||
|
public static void registerHack(long fromMessageId, long fromChatId, long fromUserId,HackType type) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -11,6 +11,9 @@ import com.pengrad.telegrambot.request.AnswerInlineQuery;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* telegram inlineQuery 功能的处理类,
|
||||||
|
* 也是一个 InlineQueryManager(还没做)
|
||||||
|
*
|
||||||
* @since 0.4.1.3
|
* @since 0.4.1.3
|
||||||
*/
|
*/
|
||||||
public class OnInlineQuery extends EventListener {
|
public class OnInlineQuery extends EventListener {
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
package cc.sukazyo.cono.morny.bot.event.on_commands;
|
||||||
|
|
||||||
|
import cc.sukazyo.cono.morny.MornyCoeur;
|
||||||
|
import cc.sukazyo.cono.morny.MornyTrusted;
|
||||||
|
import cc.sukazyo.cono.morny.bot.api.InputCommand;
|
||||||
|
import cc.sukazyo.cono.morny.bot.event.OnEventHackHandle;
|
||||||
|
import cc.sukazyo.cono.morny.data.TelegramStickers;
|
||||||
|
import com.pengrad.telegrambot.model.Update;
|
||||||
|
import com.pengrad.telegrambot.request.SendSticker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.4.2.0
|
||||||
|
*/
|
||||||
|
public class EventHack {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.4.2.0
|
||||||
|
*/
|
||||||
|
public static void exec (Update event, InputCommand command) {
|
||||||
|
|
||||||
|
boolean isOk = false;
|
||||||
|
|
||||||
|
String x_mode = "";
|
||||||
|
if (command.hasArgs()) {
|
||||||
|
x_mode = command.getArgs()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (x_mode) {
|
||||||
|
case "any":
|
||||||
|
if (MornyTrusted.isTrusted(event.message().from().id())) {
|
||||||
|
OnEventHackHandle.registerHack(
|
||||||
|
event.message().messageId(),
|
||||||
|
event.message().from().id(),
|
||||||
|
event.message().chat().id(),
|
||||||
|
OnEventHackHandle.HackType.ANY
|
||||||
|
);
|
||||||
|
isOk = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "group":
|
||||||
|
OnEventHackHandle.registerHack(
|
||||||
|
event.message().messageId(),
|
||||||
|
event.message().from().id(),
|
||||||
|
event.message().chat().id(),
|
||||||
|
OnEventHackHandle.HackType.GROUP
|
||||||
|
);
|
||||||
|
isOk = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
OnEventHackHandle.registerHack(
|
||||||
|
event.message().messageId(),
|
||||||
|
event.message().from().id(),
|
||||||
|
event.message().chat().id(),
|
||||||
|
OnEventHackHandle.HackType.USER
|
||||||
|
);
|
||||||
|
isOk = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isOk) {
|
||||||
|
MornyCoeur.getAccount().execute(new SendSticker(
|
||||||
|
event.message().chat().id(),
|
||||||
|
TelegramStickers.ID_WAITING
|
||||||
|
).replyToMessageId(event.message().messageId())
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
MornyCoeur.getAccount().execute(new SendSticker(
|
||||||
|
event.message().chat().id(),
|
||||||
|
TelegramStickers.ID_403
|
||||||
|
).replyToMessageId(event.message().messageId())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package cc.sukazyo.cono.morny.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存放 bot 使用到的贴纸
|
||||||
|
* @since 0.4.2.0
|
||||||
|
*/
|
||||||
|
public class TelegramStickers {
|
||||||
|
|
||||||
|
public static final String ID_ONLINE_STATUS_RETURN = "CAACAgEAAx0CW-CvvgAC5eBhhhODGRuu0pxKLwoQ3yMsowjviAACcycAAnj8xgVVU666si1utiIE";
|
||||||
|
public static final String ID_HELLO = "CAACAgEAAxkBAAMnYYYWKNXO4ibo9dlsmDctHhhV6fIAAqooAAJ4_MYFJJhrHS74xUAiBA";
|
||||||
|
public static final String ID_EXIT = "CAACAgEAAxkBAAMoYYYWt8UjvP0N405SAyvg2SQZmokAAkMiAAJ4_MYFw6yZLu06b-MiBA";
|
||||||
|
public static final String ID_403 = "CAACAgEAAxkBAAMqYYYa_7hpXH6hMOYMX4Nh8AVYd74AAnQnAAJ4_MYFRdmmsQKLDZgiBA";
|
||||||
|
public static final String ID_404 = "CAACAgEAAx0CSQh32gABA966YbRJpbmi2lCHINBDuo1DknSTsbsAAqUoAAJ4_MYFUa8SIaZriAojBA";
|
||||||
|
public static final String ID_WAITING = "CAACAgEAAx0CSQh32gABA-8DYbh7W2VhJ490ucfZMUMrgMR2FW4AAm4nAAJ4_MYFjx6zpxJPWsQjBA";
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user