mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-22 11:14:55 +08:00
添加自定义呼叫功能,添加 event_hack 命令与呼叫功能的 javadoc
This commit is contained in:
parent
6219773ebc
commit
12b4c91829
@ -1,6 +1,6 @@
|
||||
## Core
|
||||
|
||||
VERSION = 0.4.2.1
|
||||
VERSION = 0.4.2.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.4.2.1";
|
||||
public static final long COMPILE_TIMESTAMP = 1639494688933L;
|
||||
public static final String VERSION = "0.4.2.2";
|
||||
public static final long COMPILE_TIMESTAMP = 1639541150226L;
|
||||
}
|
||||
|
@ -7,20 +7,32 @@ import cc.sukazyo.cono.morny.data.TelegramStickers;
|
||||
import com.pengrad.telegrambot.model.Chat;
|
||||
import com.pengrad.telegrambot.model.Update;
|
||||
import com.pengrad.telegrambot.model.request.ParseMode;
|
||||
import com.pengrad.telegrambot.request.ForwardMessage;
|
||||
import com.pengrad.telegrambot.request.SendMessage;
|
||||
import com.pengrad.telegrambot.request.SendSticker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* 通过 bot 呼叫主人的事件监听管理类
|
||||
* @since 0.4.2.1
|
||||
*/
|
||||
public class OnCallMe extends EventListener {
|
||||
|
||||
/**
|
||||
* 主人的 telegram user id,同时被用于 chat id<br>
|
||||
* 跟随 {@link MornyTrusted#MASTER} 的值
|
||||
* @since 0.4.2.1
|
||||
*/
|
||||
private static final long ME = MornyTrusted.MASTER;
|
||||
|
||||
/**
|
||||
* 监听私聊 bot 的消息进行呼叫关键字匹配。
|
||||
* 如果成功,将会执行呼叫函数,并向呼叫者回显{@link TelegramStickers#ID_WAITING "已呼叫"贴纸}
|
||||
*
|
||||
* @param update 事件基础参数,消息事件所属的 tgapi:update 对象
|
||||
* @return 事件基础返回值,是否已完成处理事件:<br>
|
||||
* 如果匹配到呼叫,则返回{@code true},反之返回{@code false}
|
||||
*/
|
||||
@Override
|
||||
public boolean onMessage (@NotNull Update update) {
|
||||
if (update.message().text() == null)
|
||||
@ -28,19 +40,18 @@ public class OnCallMe extends EventListener {
|
||||
if (update.message().chat().type() != Chat.Type.Private)
|
||||
return false;
|
||||
switch (update.message().text().toLowerCase()) {
|
||||
case "steam":
|
||||
case "sbeam":
|
||||
case "sdeam":
|
||||
case "steam", "sbeam", "sdeam" ->
|
||||
requestSteamJoin(update);
|
||||
break;
|
||||
case "hana paresu":
|
||||
case "花宫":
|
||||
case "内群":
|
||||
case "hana paresu", "花宫", "内群" ->
|
||||
requestHanaParesuJoin(update);
|
||||
default -> {
|
||||
if (update.message().text().startsWith("cc::")) {
|
||||
requestCustomCall(update);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
MornyCoeur.getAccount().execute(new SendSticker(
|
||||
update.message().chat().id(),
|
||||
TelegramStickers.ID_SENT
|
||||
@ -49,6 +60,12 @@ public class OnCallMe extends EventListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行 steam library 呼叫<br>
|
||||
* 将会向 {@link #ME} 发送
|
||||
*
|
||||
* @param event 执行呼叫的tg事件
|
||||
*/
|
||||
private static void requestSteamJoin (Update event) {
|
||||
MornyCoeur.getAccount().execute(new SendMessage(
|
||||
ME, String.format("""
|
||||
@ -60,6 +77,12 @@ public class OnCallMe extends EventListener {
|
||||
).parseMode(ParseMode.HTML));
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行花宫呼叫<br>
|
||||
* 将会向 {@link #ME} 发送
|
||||
*
|
||||
* @param event 执行呼叫的tg事件
|
||||
*/
|
||||
private static void requestHanaParesuJoin (Update event) {
|
||||
MornyCoeur.getAccount().execute(new SendMessage(
|
||||
ME, String.format("""
|
||||
@ -71,4 +94,31 @@ public class OnCallMe extends EventListener {
|
||||
).parseMode(ParseMode.HTML));
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行自定义呼叫<br>
|
||||
* 将会向 {@link #ME} 发送一个 request 数据消息和转发的原始请求消息<br>
|
||||
* <br>
|
||||
* <u>known issue</u><ul>
|
||||
* <li>无法处理与转发带有媒体的消息</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param event 执行呼叫的tg事件
|
||||
* @since 0.4.2.2
|
||||
*/
|
||||
private static void requestCustomCall (Update event) {
|
||||
MornyCoeur.getAccount().execute(new SendMessage(
|
||||
ME, String.format("""
|
||||
request <u>[???]</u>
|
||||
from <a href="tg://user?id=%d">%s</a>""",
|
||||
event.message().from().id(),
|
||||
event.message().from().firstName() + " " + event.message().from().lastName()
|
||||
)
|
||||
).parseMode(ParseMode.HTML));
|
||||
MornyCoeur.getAccount().execute(new ForwardMessage(
|
||||
ME,
|
||||
event.message().chat().id(),
|
||||
event.message().messageId()
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,11 +9,20 @@ import com.pengrad.telegrambot.model.Update;
|
||||
import com.pengrad.telegrambot.request.SendSticker;
|
||||
|
||||
/**
|
||||
* {@link OnEventHackHandle} 的命令行前端
|
||||
* @since 0.4.2.0
|
||||
*/
|
||||
public class EventHack {
|
||||
|
||||
/**
|
||||
* {@link OnEventHackHandle} 的命令行前端<br>
|
||||
* <br>
|
||||
* 实现了通过命令行进行 EventHack 功能。<br>
|
||||
* 支持三种模式,默认为 {@link OnEventHackHandle.HackType#USER USER},
|
||||
* {@link OnEventHackHandle.HackType#ANY ANY} 时,将会通过 {@link MornyTrusted#isTrusted(long)} 检查触发用户的权限
|
||||
*
|
||||
* @param event 命令基础参数,触发的事件对象本身
|
||||
* @param command 命令基础参数,解析出的命令对象
|
||||
* @since 0.4.2.0
|
||||
*/
|
||||
public static void exec (Update event, InputCommand command) {
|
||||
|
@ -0,0 +1,4 @@
|
||||
package cc.sukazyo.cono.morny.bot.event.on_commands;
|
||||
|
||||
public class Roll {
|
||||
}
|
Loading…
Reference in New Issue
Block a user