2024-09-06 18:03:14 +08:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2024 RTAkland
|
|
|
|
|
* Author: RTAkland
|
|
|
|
|
* Date: 2024/9/6
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2024-09-13 12:44:10 +08:00
|
|
|
package cn.rtast.fancybot.commands.lookup
|
2024-09-06 18:03:14 +08:00
|
|
|
|
|
|
|
|
import cn.rtast.rob.entity.GroupMessage
|
|
|
|
|
import cn.rtast.rob.util.BaseCommand
|
|
|
|
|
import cn.rtast.rob.util.ob.MessageChain
|
2024-09-19 11:06:40 +08:00
|
|
|
import cn.rtast.rob.util.ob.OneBotListener
|
2024-09-25 18:18:28 +08:00
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
|
import kotlinx.coroutines.withContext
|
2024-09-06 18:03:14 +08:00
|
|
|
import java.net.InetAddress
|
|
|
|
|
|
|
|
|
|
class NslookupCommand : BaseCommand() {
|
|
|
|
|
override val commandNames = listOf("/nslookup", "/ns")
|
|
|
|
|
|
2024-09-19 11:06:40 +08:00
|
|
|
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
2024-09-06 18:03:14 +08:00
|
|
|
val msg = MessageChain.Builder()
|
|
|
|
|
.addReply(message.messageId)
|
|
|
|
|
.addText("域名: ${args.first()}解析后的IP地址为: ")
|
2024-09-25 18:18:28 +08:00
|
|
|
.addText(withContext(Dispatchers.IO) {
|
|
|
|
|
InetAddress.getByName(args.first())
|
|
|
|
|
}.hostAddress)
|
2024-09-06 18:03:14 +08:00
|
|
|
.build()
|
|
|
|
|
listener.sendGroupMessage(message.groupId, msg)
|
|
|
|
|
}
|
|
|
|
|
}
|