diff --git a/gradle.properties b/gradle.properties
index 284e63c..0e8762b 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,6 +1,6 @@
## Core
-VERSION = 0.4.3.3
+VERSION = 0.4.3.4
# dependencies
diff --git a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java
index 033315e..a927157 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.3";
- public static final long COMPILE_TIMESTAMP = 1641752627626L;
+ public static final String VERSION = "0.4.3.4";
+ public static final long COMPILE_TIMESTAMP = 1642273245554L;
}
diff --git a/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java b/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java
index 7f8a239..b745d2d 100644
--- a/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java
+++ b/src/main/java/cc/sukazyo/cono/morny/MornyCoeur.java
@@ -3,6 +3,8 @@ package cc.sukazyo.cono.morny;
import cc.sukazyo.cono.morny.bot.api.OnUpdate;
import cc.sukazyo.cono.morny.bot.event.EventListeners;
import cc.sukazyo.cono.morny.data.tracker.TrackerDataManager;
+import cc.sukazyo.untitled.telegram.api.extra.ExtraAction;
+
import com.pengrad.telegrambot.TelegramBot;
import com.pengrad.telegrambot.request.GetMe;
@@ -25,6 +27,7 @@ public class MornyCoeur {
/** morny 的 bot 账户 */
private final TelegramBot account;
+ private final ExtraAction extraActionInstance;
/**
* morny 的 bot 账户的用户名
*
@@ -95,6 +98,8 @@ public class MornyCoeur {
throw ex;
}
+ this.extraActionInstance = ExtraAction.as(account);
+
logger.info("Bot login succeed.");
}
@@ -224,4 +229,9 @@ public class MornyCoeur {
return INSTANCE.trusted;
}
+ @Nonnull
+ public static ExtraAction extra () {
+ return INSTANCE.extraActionInstance;
+ }
+
}
diff --git a/src/main/java/cc/sukazyo/cono/morny/MornyTrusted.java b/src/main/java/cc/sukazyo/cono/morny/MornyTrusted.java
index f892b9d..eb9305e 100644
--- a/src/main/java/cc/sukazyo/cono/morny/MornyTrusted.java
+++ b/src/main/java/cc/sukazyo/cono/morny/MornyTrusted.java
@@ -1,7 +1,6 @@
package cc.sukazyo.cono.morny;
-import com.pengrad.telegrambot.model.ChatMember;
-import com.pengrad.telegrambot.request.GetChatMember;
+import com.pengrad.telegrambot.model.ChatMember.Status;
/**
* 对用户进行身份权限验证的管理类
@@ -37,13 +36,7 @@ public class MornyTrusted {
*/
public boolean isTrusted (long userId) {
if (userId == MASTER) return true;
- final ChatMember chatMember = MornyCoeur.getAccount().execute(new GetChatMember(TRUSTED_CHAT_ID, userId)).chatMember();
- return (
- chatMember != null && (
- chatMember.status() == ChatMember.Status.administrator ||
- chatMember.status() == ChatMember.Status.creator
- )
- );
+ return MornyCoeur.extra().isUserInGroup(userId, TRUSTED_CHAT_ID, Status.administrator);
}
}
diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/api/EventListenerManager.java b/src/main/java/cc/sukazyo/cono/morny/bot/api/EventListenerManager.java
index 5291509..f38d94a 100644
--- a/src/main/java/cc/sukazyo/cono/morny/bot/api/EventListenerManager.java
+++ b/src/main/java/cc/sukazyo/cono/morny/bot/api/EventListenerManager.java
@@ -3,6 +3,8 @@ package cc.sukazyo.cono.morny.bot.api;
import com.google.gson.GsonBuilder;
import com.pengrad.telegrambot.model.Update;
+import cc.sukazyo.untitled.telegram.api.event.EventRuntimeException;
+
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/api/EventRuntimeException.java b/src/main/java/cc/sukazyo/cono/morny/bot/api/EventRuntimeException.java
deleted file mode 100644
index 18b9366..0000000
--- a/src/main/java/cc/sukazyo/cono/morny/bot/api/EventRuntimeException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package cc.sukazyo.cono.morny.bot.api;
-
-import com.pengrad.telegrambot.response.BaseResponse;
-
-public class EventRuntimeException extends RuntimeException {
-
- public EventRuntimeException () {
- super();
- }
-
- public EventRuntimeException (String message) {
- super(message);
- }
-
- public static class ActionFailed extends EventRuntimeException {
-
- private final BaseResponse response;
-
- public ActionFailed (BaseResponse response) {
- super();
- this.response = response;
- }
-
- public ActionFailed (String message, BaseResponse response) {
- super(message);
- this.response = response;
- }
-
- public BaseResponse getResponse() {
- return response;
- }
-
- }
-
-}
diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/api/Executor.java b/src/main/java/cc/sukazyo/cono/morny/bot/api/Executor.java
deleted file mode 100644
index 4d89e3e..0000000
--- a/src/main/java/cc/sukazyo/cono/morny/bot/api/Executor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package cc.sukazyo.cono.morny.bot.api;
-
-import com.pengrad.telegrambot.TelegramBot;
-import com.pengrad.telegrambot.request.BaseRequest;
-import com.pengrad.telegrambot.response.BaseResponse;
-
-public class Executor {
-
- private final TelegramBot client;
-
- public Executor (TelegramBot bot) {
- client = bot;
- }
-
- public static Executor as (TelegramBot bot) {
- return new Executor(bot);
- }
-
- public , R extends BaseResponse> R exec (T req) {
- return exec(req, "");
- }
-
- public , R extends BaseResponse> R exec (T req, String errorMessage) {
- final R resp = client.execute(req);
- if (!resp.isOk()) throw new EventRuntimeException.ActionFailed(
- (errorMessage.equals("") ? String.valueOf(resp.errorCode()) : errorMessage),
- resp
- );
- return resp;
- }
-
-}
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 94d3138..f5b80d9 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
@@ -3,7 +3,6 @@ package cc.sukazyo.cono.morny.bot.event;
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.bot.api.Executor;
import cc.sukazyo.cono.morny.data.TelegramStickers;
import com.pengrad.telegrambot.model.Chat;
import com.pengrad.telegrambot.model.Update;
@@ -56,7 +55,7 @@ public class OnCallMe extends EventListener {
return false;
}
}
- Executor.as(MornyCoeur.getAccount()).exec(new SendSticker(
+ MornyCoeur.extra().exec(new SendSticker(
update.message().chat().id(),
TelegramStickers.ID_SENT
).replyToMessageId(update.message().messageId())
@@ -71,7 +70,7 @@ public class OnCallMe extends EventListener {
* @param event 执行呼叫的tg事件
*/
private static void requestSteamJoin (Update event) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
ME, String.format(
"""
request STEAM LIBRARY
@@ -91,7 +90,7 @@ public class OnCallMe extends EventListener {
* @param event 执行呼叫的tg事件
*/
private static void requestHanaParesuJoin (Update event) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
ME, String.format(
"""
request Hana Paresu
@@ -119,7 +118,7 @@ public class OnCallMe extends EventListener {
* @since 0.4.2.2
*/
private static void requestCustomCall (Update event) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
ME, String.format(
"""
request [???]
@@ -130,7 +129,7 @@ public class OnCallMe extends EventListener {
)
)
).parseMode(ParseMode.HTML));
- Executor.as(MornyCoeur.getAccount()).exec(new ForwardMessage(
+ MornyCoeur.extra().exec(new ForwardMessage(
ME,
event.message().chat().id(),
event.message().messageId()
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 1f6566d..f4febb9 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
@@ -4,7 +4,6 @@ import cc.sukazyo.cono.morny.GradleProjectConfigures;
import cc.sukazyo.cono.morny.MornyCoeur;
import cc.sukazyo.cono.morny.MornySystem;
import cc.sukazyo.cono.morny.bot.api.EventListener;
-import cc.sukazyo.cono.morny.bot.api.Executor;
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.Ip186Query;
@@ -81,7 +80,7 @@ public class OnCommandExecute extends EventListener {
private boolean nonCommandExecutable (Update event, InputCommand command) {
if (command.getTarget() == null) return false; // 无法解析的命令,转交事件链后代处理
else { // 无法解析的显式命令格式,报错找不到命令
- Executor.as(MornyCoeur.getAccount()).exec(new SendSticker(
+ MornyCoeur.extra().exec(new SendSticker(
event.message().chat().id(),
TelegramStickers.ID_404
).replyToMessageId(event.message().messageId())
@@ -91,7 +90,7 @@ public class OnCommandExecute extends EventListener {
}
private void onCommandOnExec (@Nonnull Update event) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendSticker(
+ MornyCoeur.extra().exec(new SendSticker(
event.message().chat().id(),
TelegramStickers.ID_ONLINE_STATUS_RETURN
).replyToMessageId(event.message().messageId())
@@ -99,7 +98,7 @@ public class OnCommandExecute extends EventListener {
}
private void onCommandHelloExec (@Nonnull Update event) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendSticker(
+ MornyCoeur.extra().exec(new SendSticker(
event.message().chat().id(),
TelegramStickers.ID_HELLO
).replyToMessageId(event.message().messageId())
@@ -108,7 +107,7 @@ public class OnCommandExecute extends EventListener {
private void onCommandExitExec (@Nonnull Update event) {
if (MornyCoeur.trustedInstance().isTrusted(event.message().from().id())) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendSticker(
+ MornyCoeur.extra().exec(new SendSticker(
event.message().chat().id(),
TelegramStickers.ID_EXIT
).replyToMessageId(event.message().messageId())
@@ -116,7 +115,7 @@ public class OnCommandExecute extends EventListener {
logger.info("Morny exited by user @" + event.message().from().username());
System.exit(0);
} else {
- Executor.as(MornyCoeur.getAccount()).exec(new SendSticker(
+ MornyCoeur.extra().exec(new SendSticker(
event.message().chat().id(),
TelegramStickers.ID_403
).replyToMessageId(event.message().messageId())
@@ -126,7 +125,7 @@ public class OnCommandExecute extends EventListener {
}
private void onCommandVersionExec (@Nonnull Update event) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
String.format(
"""
@@ -134,7 +133,7 @@ public class OnCommandExecute extends EventListener {
- %s
core md5_hash:
- %s
- compile time<mp:
+ compile timestamp:
- %d
- %s [UTC]
""",
escapeHtml(MornySystem.VERSION),
@@ -149,7 +148,7 @@ public class OnCommandExecute extends EventListener {
* @since 0.4.1.2
*/
private void onCommandRuntimeExec (@Nonnull Update event) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
String.format("""
system:
@@ -198,7 +197,7 @@ public class OnCommandExecute extends EventListener {
private void onCommandJrrpExec (Update event) {
final double jrrp = MornyJrrp.getJrrpFromTelegramUser(event.message().from(), System.currentTimeMillis());
final String endChar = jrrp>70 ? "!" : jrrp>30 ? ";" : "...";
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
String.format(
"%s 在(utc的)今天的运气指数是———— %.2f%%
%s",
@@ -216,13 +215,13 @@ public class OnCommandExecute extends EventListener {
if (MornyCoeur.trustedInstance().isTrusted(event.message().from().id())) {
logger.info(String.format("called save from command by @%s.", event.message().from().username()));
MornyCoeur.callSaveData();
- Executor.as(MornyCoeur.getAccount()).exec(new SendSticker(
+ MornyCoeur.extra().exec(new SendSticker(
event.message().chat().id(),
TelegramStickers.ID_SAVED
).replyToMessageId(event.message().messageId())
);
} else {
- Executor.as(MornyCoeur.getAccount()).exec(new SendSticker(
+ MornyCoeur.extra().exec(new SendSticker(
event.message().chat().id(),
TelegramStickers.ID_403
).replyToMessageId(event.message().messageId())
diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnEventHackHandle.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnEventHackHandle.java
index f4d0aa0..a85a980 100644
--- a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnEventHackHandle.java
+++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnEventHackHandle.java
@@ -2,7 +2,6 @@ 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.bot.api.Executor;
import cc.sukazyo.untitled.util.telegram.formatting.MsgEscape;
import com.google.gson.GsonBuilder;
@@ -66,7 +65,7 @@ public class OnEventHackHandle extends EventListener {
if (x == null) x = hackers.remove("[[]]");
if (x == null) return false;
logger.debug("hacked event by " + x);
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(x.fromChatId, String.format(
+ MornyCoeur.extra().exec(new SendMessage(x.fromChatId, String.format(
"%s
",
MsgEscape.escapeHtml(new GsonBuilder().setPrettyPrinting().create().toJson(update))
)).parseMode(ParseMode.HTML).replyToMessageId((int)x.fromMessageId));
diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnInlineQuery.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnInlineQuery.java
index 7caaa63..5a64be5 100644
--- a/src/main/java/cc/sukazyo/cono/morny/bot/event/OnInlineQuery.java
+++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/OnInlineQuery.java
@@ -2,7 +2,6 @@ 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.bot.api.Executor;
import cc.sukazyo.cono.morny.util.EncryptUtils;
import com.pengrad.telegrambot.model.Update;
import com.pengrad.telegrambot.model.request.InlineQueryResultArticle;
@@ -25,7 +24,7 @@ public class OnInlineQuery extends EventListener {
*/
@Override
public boolean onInlineQuery (@Nonnull Update update) {
- Executor.as(MornyCoeur.getAccount()).exec(new AnswerInlineQuery(update.inlineQuery().id(), new InlineQueryResultArticle[]{
+ MornyCoeur.extra().exec(new AnswerInlineQuery(update.inlineQuery().id(), new InlineQueryResultArticle[]{
new InlineQueryResultArticle(
EncryptUtils.encryptByMD5(update.inlineQuery().query()),
"Raw Input",
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 ce02efa..d220b4c 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,7 +2,6 @@ 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.bot.api.Executor;
import cc.sukazyo.untitled.util.command.CommonCommand;
import cc.sukazyo.untitled.util.string.StringArrays;
@@ -49,7 +48,7 @@ public class OnUserSlashAction extends EventListener {
event.message().replyToMessage().from()
));
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
String.format(
"%s %s%s %s%s%s",
diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/EventHack.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/EventHack.java
index 60eea5d..36e2571 100644
--- a/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/EventHack.java
+++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/EventHack.java
@@ -2,7 +2,6 @@ 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.Executor;
import cc.sukazyo.cono.morny.bot.event.OnEventHackHandle;
import cc.sukazyo.cono.morny.data.TelegramStickers;
import cc.sukazyo.untitled.util.telegram.object.InputCommand;
@@ -66,13 +65,13 @@ public class EventHack {
}
if (isOk) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendSticker(
+ MornyCoeur.extra().exec(new SendSticker(
event.message().chat().id(),
TelegramStickers.ID_WAITING
).replyToMessageId(event.message().messageId())
);
} else {
- Executor.as(MornyCoeur.getAccount()).exec(new SendSticker(
+ MornyCoeur.extra().exec(new SendSticker(
event.message().chat().id(),
TelegramStickers.ID_403
).replyToMessageId(event.message().messageId())
diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/GetUsernameAndId.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/GetUsernameAndId.java
index 2fc1fc1..24fb3df 100644
--- a/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/GetUsernameAndId.java
+++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/GetUsernameAndId.java
@@ -1,7 +1,6 @@
package cc.sukazyo.cono.morny.bot.event.on_commands;
import cc.sukazyo.cono.morny.MornyCoeur;
-import cc.sukazyo.cono.morny.bot.api.Executor;
import com.pengrad.telegrambot.model.Update;
import com.pengrad.telegrambot.model.User;
@@ -18,7 +17,7 @@ public class GetUsernameAndId {
public static void exec (@Nonnull String[] args, @Nonnull Update event) {
- if (args.length > 1) { Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ if (args.length > 1) { MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
"[Unavailable] Too much arguments."
).replyToMessageId(event.message().messageId())); return; }
@@ -32,7 +31,7 @@ public class GetUsernameAndId {
try {
userId = Long.parseLong(args[0]);
} catch (NumberFormatException e) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
"[Unavailable] " + e.getMessage()
).replyToMessageId(event.message().messageId()));
@@ -40,12 +39,12 @@ public class GetUsernameAndId {
}
}
- final GetChatMemberResponse response = Executor.as(MornyCoeur.getAccount()).exec(
+ final GetChatMemberResponse response = MornyCoeur.extra().exec(
new GetChatMember(event.message().chat().id(), userId)
);
if (response.chatMember() == null) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
"[Unavailable] user not found."
).replyToMessageId(event.message().messageId()));
@@ -104,7 +103,7 @@ public class GetUsernameAndId {
));
}
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
userInformation.toString()
).replyToMessageId(event.message().messageId()).parseMode(ParseMode.HTML));
diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/Ip186Query.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/Ip186Query.java
index 5f56eb4..48c7f86 100644
--- a/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/Ip186Query.java
+++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/Ip186Query.java
@@ -1,7 +1,6 @@
package cc.sukazyo.cono.morny.bot.event.on_commands;
import cc.sukazyo.cono.morny.MornyCoeur;
-import cc.sukazyo.cono.morny.bot.api.Executor;
import cc.sukazyo.cono.morny.data.ip186.IP186QueryResponse;
import cc.sukazyo.untitled.util.telegram.object.InputCommand;
import cc.sukazyo.cono.morny.data.ip186.IP186QueryHandler;
@@ -27,7 +26,7 @@ public class Ip186Query {
arg = event.message().replyToMessage().text();
}
} else if (command.getArgs().length > 1) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
"[Unavailable] Too much arguments."
).replyToMessageId(event.message().messageId()));
@@ -36,7 +35,7 @@ public class Ip186Query {
arg = command.getArgs()[0];
}
if (arg == null) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
"[Unavailable] No ip defined."
).replyToMessageId(event.message().messageId()));
@@ -49,12 +48,12 @@ public class Ip186Query {
case "/whois" -> IP186QueryHandler.queryWhois(arg);
default -> throw new IllegalArgumentException("Unknown 186-IP query method " + command.getCommand());
};
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
escapeHtml(response.url()) + "\n" + escapeHtml(response.body()) + "
"
).parseMode(ParseMode.HTML).replyToMessageId(event.message().messageId()));
} catch (Exception e) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
"[Exception] in query:\n" + escapeHtml(e.getMessage()) + "
"
).parseMode(ParseMode.HTML).replyToMessageId(event.message().messageId()));
diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/Nbnhhsh.java b/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/Nbnhhsh.java
index dcd449c..8cf4649 100644
--- a/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/Nbnhhsh.java
+++ b/src/main/java/cc/sukazyo/cono/morny/bot/event/on_commands/Nbnhhsh.java
@@ -5,7 +5,6 @@ import com.pengrad.telegrambot.model.request.ParseMode;
import com.pengrad.telegrambot.request.SendMessage;
import cc.sukazyo.cono.morny.MornyCoeur;
-import cc.sukazyo.cono.morny.bot.api.Executor;
import cc.sukazyo.cono.morny.data.NbnhhshQuery;
import cc.sukazyo.untitled.util.string.StringArrays;
import cc.sukazyo.untitled.util.telegram.object.InputCommand;
@@ -36,13 +35,13 @@ public class Nbnhhsh {
}
}
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
message.toString()
).parseMode(ParseMode.HTML).replyToMessageId(event.message().messageId()));
} catch (Exception e) {
- Executor.as(MornyCoeur.getAccount()).exec(new SendMessage(
+ MornyCoeur.extra().exec(new SendMessage(
event.message().chat().id(),
"[Exception] in query:\n" + escapeHtml(e.getMessage()) + "
"
).parseMode(ParseMode.HTML).replyToMessageId(event.message().messageId()));