Initial commit

This commit is contained in:
筱傑
2021-11-03 00:16:33 +08:00
commit 4443777049
12 changed files with 511 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
package me.jie65535.jnr
import net.mamoe.mirai.console.command.CommandSender
import net.mamoe.mirai.console.command.RawCommand
import net.mamoe.mirai.message.data.MessageChain
object JNRCommand : RawCommand(
JNudgeReply, "jnr", "setPokeReply", "setNudgeReply",
usage = "/jnr|setPokeReply|setNudgeReply <message> # 设置戳一戳回复消息",
description = "设置戳一戳回复消息"
) {
override suspend fun CommandSender.onCommand(args: MessageChain) {
JNRPluginConfig.replyMessage = args.serializeToMiraiCode()
sendMessage("OK")
}
}

View File

@@ -0,0 +1,36 @@
package me.jie65535.jnr
import net.mamoe.mirai.console.data.AutoSavePluginConfig
import net.mamoe.mirai.console.data.ValueDescription
import net.mamoe.mirai.console.data.value
import net.mamoe.mirai.event.EventPriority
import net.mamoe.mirai.message.data.Message
import net.mamoe.mirai.message.data.MessageChain
import net.mamoe.mirai.message.data.MessageChainBuilder
/**
* 插件配置
*/
object JNRPluginConfig : AutoSavePluginConfig("jnr") {
/**
* 回复的消息
* @see Message
*/
@ValueDescription("戳一戳回复的消息")
var replyMessage: String by value()
/**
* 优先级 默认为高
* @see EventPriority
*/
@ValueDescription("事件优先级 从高到低可选 HIGHEST, HIGH, NORMAL, LOW, LOWEST, MONITOR\n" +
"设置后需要重启插件生效")
var priority: EventPriority by value(EventPriority.HIGH)
/**
* 是否拦截事件 为true时优先级较低的
* @see EventPriority
*/
@ValueDescription("是否拦截事件 回复后可阻止其它插件响应戳一戳事件 优先级为MONITOR时拦截无效")
var isIntercept: Boolean by value(true)
}

View File

@@ -0,0 +1,41 @@
package me.jie65535.jnr
import net.mamoe.mirai.console.command.CommandManager.INSTANCE.register
import net.mamoe.mirai.console.command.CommandManager.INSTANCE.unregister
import net.mamoe.mirai.console.data.AutoSavePluginConfig
import net.mamoe.mirai.console.data.value
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription
import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin
import net.mamoe.mirai.event.EventPriority
import net.mamoe.mirai.event.events.NudgeEvent
import net.mamoe.mirai.event.globalEventChannel
import net.mamoe.mirai.message.code.MiraiCode.deserializeMiraiCode
import net.mamoe.mirai.message.data.Message
import net.mamoe.mirai.message.data.isContentBlank
import net.mamoe.mirai.utils.info
object JNudgeReply : KotlinPlugin(
JvmPluginDescription(
id = "me.jie65535.mirai-console-jnr-plugin",
name = "J Nudge Reply",
version = "0.1.0",
) {
author("jie65535")
info("""自定义戳一戳回复插件""")
}
) {
override fun onEnable() {
JNRPluginConfig.reload()
JNRCommand.register()
globalEventChannel().subscribeAlways<NudgeEvent>(priority = JNRPluginConfig.priority) {
if (target.id == bot.id && JNRPluginConfig.replyMessage.isNotEmpty()) {
subject.sendMessage(JNRPluginConfig.replyMessage.deserializeMiraiCode())
if (JNRPluginConfig.priority != EventPriority.MONITOR && JNRPluginConfig.isIntercept)
intercept()
}
}
logger.info { "Plugin loaded" }
}
}

View File

@@ -0,0 +1 @@
me.jie65535.jnr.JNudgeReply