feat: add shot command

This commit is contained in:
2024-09-23 16:57:59 +08:00
parent 8b297e556c
commit d42dcee322
2 files changed
+59 -13

No files matched your search

+3 -13
View File
@@ -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
@@ -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<String>) {
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<String>) {
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!!))
}
}