mirror of
https://github.com/jie65535/mirai-console-jnr-plugin.git
synced 2025-06-02 17:49:11 +08:00
增加翻页参数到list
子命令
更新版本到v1.2.1
This commit is contained in:
parent
f8c7485eca
commit
f20fd9b807
@ -8,7 +8,7 @@ MiraiConsolePlugin 自定义戳一戳回复消息
|
||||
/jnr add [weight] # 添加回复消息(权重默认为1)
|
||||
/jnr add <message> [weight] # 添加简单回复消息(权重默认为1)
|
||||
/jnr clear # 清空回复消息列表
|
||||
/jnr list # 列出当前回复消息列表
|
||||
/jnr list [page] [pageSize] # 列出当前回复消息列表,参数可翻页
|
||||
/jnr remove <index> # 删除指定索引的回复消息
|
||||
/jnr reload # 重载配置
|
||||
```
|
||||
|
@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "top.jie65535"
|
||||
version = "1.2.0"
|
||||
version = "1.2.1"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
|
@ -15,6 +15,7 @@ import net.mamoe.mirai.message.data.PlainText
|
||||
import net.mamoe.mirai.message.data.buildForwardMessage
|
||||
import net.mamoe.mirai.message.data.isContentBlank
|
||||
import top.jie65535.jnr.JNudgeReply.reload
|
||||
import kotlin.math.min
|
||||
|
||||
object JNRCommand : CompositeCommand(
|
||||
JNudgeReply, "jnr",
|
||||
@ -84,7 +85,7 @@ object JNRCommand : CompositeCommand(
|
||||
|
||||
@SubCommand
|
||||
@Description("列出当前回复消息列表")
|
||||
suspend fun CommandSender.list() {
|
||||
suspend fun CommandSender.list(page: Int = 0, pageSize: Int = 50) {
|
||||
val list = JNRPluginConfig.replyMessageList
|
||||
if (list.isEmpty()) {
|
||||
sendMessage("当前列表为空")
|
||||
@ -97,11 +98,20 @@ object JNRCommand : CompositeCommand(
|
||||
sendMessage(sb.toString())
|
||||
}, {
|
||||
if (list.size > 1) {
|
||||
val begin = page * pageSize
|
||||
val end = min(list.size, (page + 1) * pageSize)
|
||||
if (begin < 0 || end <= begin) {
|
||||
sendMessage("翻页参数错误")
|
||||
} else {
|
||||
sendMessage(buildForwardMessage(subject) {
|
||||
for (i in list.indices) {
|
||||
for (i in begin until end) {
|
||||
bot named "[$i] (${list[i].weight})" says list[i].message.deserializeMiraiCode()
|
||||
}
|
||||
if (end < list.size) {
|
||||
bot says "当前显示 $begin~$end 共 ${list.size}"
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
sendMessage(list[0].message.deserializeMiraiCode())
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ object JNudgeReply : KotlinPlugin(
|
||||
JvmPluginDescription(
|
||||
id = "me.jie65535.mirai-console-jnr-plugin",
|
||||
name = "J Nudge Reply",
|
||||
version = "1.2.0",
|
||||
version = "1.2.1",
|
||||
) {
|
||||
author("jie65535")
|
||||
info("""自定义戳一戳回复插件""")
|
||||
|
Loading…
Reference in New Issue
Block a user