diff --git a/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt b/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt index 861cef0..2d00301 100644 --- a/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt +++ b/src/main/kotlin/cn/rtast/fancybot/FancyBot.kt @@ -11,18 +11,7 @@ import cn.rtast.fancybot.commands.AboutCommand import cn.rtast.fancybot.commands.EchoCommand import cn.rtast.fancybot.commands.HelpCommand import cn.rtast.fancybot.commands.StatusCommand -import cn.rtast.fancybot.commands.lookup.AICommand -import cn.rtast.fancybot.commands.lookup.CigaretteCommand -import cn.rtast.fancybot.commands.lookup.DomainPriceCommand -import cn.rtast.fancybot.commands.lookup.GithubUserCommand -import cn.rtast.fancybot.commands.lookup.MCPingCommand -import cn.rtast.fancybot.commands.lookup.MusicCommand -import cn.rtast.fancybot.commands.lookup.MusicPlayUrlCommand -import cn.rtast.fancybot.commands.lookup.NslookupCommand -import cn.rtast.fancybot.commands.lookup.PixivCommand -import cn.rtast.fancybot.commands.lookup.QRCodeCommand -import cn.rtast.fancybot.commands.lookup.WeatherCommand -import cn.rtast.fancybot.commands.lookup.WikipediaCommand +import cn.rtast.fancybot.commands.lookup.* import cn.rtast.fancybot.commands.misc.* import cn.rtast.fancybot.commands.parse.AsciiArtCommand import cn.rtast.fancybot.commands.parse.BVParseCommand @@ -219,7 +208,8 @@ val commands = listOf( UnsetZiBiCommand(), WikipediaCommand(), AsciiArtCommand(), StatusCommand(), JueCommand(), ShortLinkCommand(), - TenSetuCommand() + TenSetuCommand(), ShotSelfCommand(), + ShotOtherCommand() ) val START_UP_TIME = Instant.now().epochSecond diff --git a/src/main/kotlin/cn/rtast/fancybot/commands/lookup/ShotSelfCommand.kt b/src/main/kotlin/cn/rtast/fancybot/commands/lookup/ShotSelfCommand.kt new file mode 100644 index 0000000..423dec2 --- /dev/null +++ b/src/main/kotlin/cn/rtast/fancybot/commands/lookup/ShotSelfCommand.kt @@ -0,0 +1,56 @@ +/* + * Copyright © 2024 RTAkland + * Author: RTAkland + * Date: 2024/9/23 + */ + + +package cn.rtast.fancybot.commands.lookup + +import cn.rtast.rob.entity.GroupMessage +import cn.rtast.rob.enums.ArrayMessageType +import cn.rtast.rob.segment.Node +import cn.rtast.rob.segment.PlainText +import cn.rtast.rob.util.BaseCommand +import cn.rtast.rob.util.ob.NodeMessageChain +import cn.rtast.rob.util.ob.OneBotListener + + +private fun generateNodeMessage(targetName: String, targetId: String, times: Int = 10): NodeMessageChain { + val nodeMsg = NodeMessageChain.Builder() + repeat(times) { + val node = Node( + Node.Data( + targetName, + targetId, + listOf(PlainText(PlainText.Data("我是傻逼"))) + ) + ) + nodeMsg.addNode(node) + } + return nodeMsg.build() +} + +class ShotSelfCommand : BaseCommand() { + override val commandNames = listOf("骂我") + + override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List) { + listener.sendGroupForwardMsg( + message.groupId, + generateNodeMessage(message.sender.nickname, message.sender.userId.toString()) + ) + } +} + +class ShotOtherCommand : BaseCommand() { + override val commandNames = listOf("骂") + + override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List) { + if (args.isEmpty()) { + message.reply("发送`骂 @某人`可以骂他~") + return + } + val target = message.message.find { it.type == ArrayMessageType.at }?.data!! + listener.sendGroupForwardMsg(message.groupId, generateNodeMessage(target.name!!, target.qq!!)) + } +} \ No newline at end of file