feat: add random song command
This commit is contained in:
4 files changed
+56
-1
No files matched your search
@@ -106,5 +106,5 @@ val commands = listOf(
|
||||
NiuziRankCommand(), NiuziBankRankCommand(),
|
||||
ShotSelfCommand(), TenSetuCommand(),
|
||||
ReactionCommand(), MCSkinCommand(),
|
||||
GithubLatestCommitCommand()
|
||||
GithubLatestCommitCommand(), RandomMusicCommand()
|
||||
)
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package cn.rtast.fancybot.commands.misc
|
||||
|
||||
import cn.rtast.fancybot.annotations.CommandDescription
|
||||
import cn.rtast.fancybot.configManager
|
||||
import cn.rtast.fancybot.entity.bullshit.BullShit
|
||||
import cn.rtast.fancybot.util.Resources
|
||||
@@ -18,6 +19,7 @@ import cn.rtast.rob.util.ob.NodeMessageChain
|
||||
import cn.rtast.rob.util.ob.OneBotListener
|
||||
import kotlin.random.Random
|
||||
|
||||
@CommandDescription("狗屁不通文章生成器")
|
||||
class BullShitGenerateCommand : BaseCommand() {
|
||||
override val commandNames = listOf("/gpbt", "狗屁不通")
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright © 2024 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 2024/10/3
|
||||
*/
|
||||
|
||||
|
||||
package cn.rtast.fancybot.commands.misc
|
||||
|
||||
import cn.rtast.fancybot.annotations.CommandDescription
|
||||
import cn.rtast.fancybot.configManager
|
||||
import cn.rtast.fancybot.entity.music.TopSong
|
||||
import cn.rtast.fancybot.util.Http
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
import cn.rtast.rob.enums.MusicShareType
|
||||
import cn.rtast.rob.util.BaseCommand
|
||||
import cn.rtast.rob.util.ob.MessageChain
|
||||
import cn.rtast.rob.util.ob.OneBotListener
|
||||
|
||||
@CommandDescription("获取随机热榜音乐(网易云)")
|
||||
class RandomMusicCommand : BaseCommand() {
|
||||
override val commandNames = listOf("随机音乐", "随机歌曲")
|
||||
|
||||
private val ncmApiUrl = "${configManager.ncmAPI}/top/song"
|
||||
|
||||
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
||||
val id = Http.get<TopSong>(ncmApiUrl).data.random().privilege.id
|
||||
val msg = MessageChain.Builder()
|
||||
.addMusicShare(MusicShareType.Netease, id.toString())
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright © 2024 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 2024/10/3
|
||||
*/
|
||||
|
||||
|
||||
package cn.rtast.fancybot.entity.music
|
||||
|
||||
data class TopSong(
|
||||
val data: List<Data>
|
||||
) {
|
||||
data class Data(
|
||||
val privilege: Privilege
|
||||
)
|
||||
|
||||
data class Privilege(
|
||||
val id: Long
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user