feat: add some command
This commit is contained in:
5 files changed
+169
-3
No files matched your search
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright © 2024 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 2024/9/6
|
||||
*/
|
||||
|
||||
|
||||
package cn.rtast.fancybot.commands.misc
|
||||
|
||||
import cn.rtast.fancybot.entity.bili.BVID
|
||||
import cn.rtast.fancybot.util.Http
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
import cn.rtast.rob.util.ob.MessageChain
|
||||
import cn.rtast.rob.util.ob.OBMessage
|
||||
|
||||
object BVParseCommand {
|
||||
|
||||
private const val CID_URL = "https://api.bilibili.com/x/web-interface/view"
|
||||
|
||||
suspend fun parse(listener: OBMessage, message: GroupMessage) {
|
||||
val bvid = if (message.rawMessage.startsWith("BV")) {
|
||||
message.rawMessage
|
||||
} else {
|
||||
message.rawMessage.split("/")[4]
|
||||
}
|
||||
val cidResponse = Http.get<BVID>(
|
||||
CID_URL, mapOf("bvid" to bvid)
|
||||
)
|
||||
val msg = MessageChain.Builder()
|
||||
.addAt(message.sender.userId)
|
||||
.addImage(cidResponse.data.pic)
|
||||
.addText("标题: ${cidResponse.data.title} | 作者: ${cidResponse.data.owner.name}")
|
||||
.addNewLine()
|
||||
.addText("点赞: ${cidResponse.data.stat.like} | 观看: ${cidResponse.data.stat.view}")
|
||||
.addNewLine()
|
||||
.addText("收藏: ${cidResponse.data.stat.favorite} | 投币: ${cidResponse.data.stat.coin}")
|
||||
.addNewLine()
|
||||
.addText("https://www.bilibili.com/video/$bvid")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright © 2024 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 2024/9/6
|
||||
*/
|
||||
|
||||
|
||||
package cn.rtast.fancybot.commands.misc
|
||||
|
||||
import cn.rtast.rob.entity.GetMessage
|
||||
import cn.rtast.rob.enums.ArrayMessageType
|
||||
import cn.rtast.rob.util.ob.MessageChain
|
||||
import cn.rtast.rob.util.ob.OBMessage
|
||||
|
||||
object ImageURLCommand {
|
||||
|
||||
suspend fun callback(listener: OBMessage, message: GetMessage) {
|
||||
val image = message.data.message.find { it.type == ArrayMessageType.image }!!
|
||||
val msg = MessageChain.Builder()
|
||||
.addReply(message.data.messageId)
|
||||
.addAt(message.data.sender.userId)
|
||||
.addNewLine()
|
||||
.addText("哈哈哈哈图片来咯~")
|
||||
.addNewLine()
|
||||
.addText(image.data.file!!)
|
||||
.build()
|
||||
listener.sendGroupMessage(message.data.groupId!!, msg)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user