chore: add command description annotation
This commit is contained in:
5 files changed
+12
-1
No files matched your search
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright © 2024 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 2024/10/10
|
||||
*/
|
||||
|
||||
|
||||
package cn.rtast.fancybot.commands.lookup
|
||||
|
||||
import cn.rtast.fancybot.annotations.CommandDescription
|
||||
import cn.rtast.fancybot.configManager
|
||||
import cn.rtast.fancybot.entity.apispace.IdiomExplainResponse
|
||||
import cn.rtast.fancybot.util.Http
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
import cn.rtast.rob.util.BaseCommand
|
||||
import cn.rtast.rob.util.ob.MessageChain
|
||||
import cn.rtast.rob.util.ob.OneBotListener
|
||||
|
||||
@CommandDescription("解释一个成语")
|
||||
class IdiomExplainCommand : BaseCommand() {
|
||||
override val commandNames = listOf("成语解释")
|
||||
|
||||
private val apiSpaceUrl = "https://eolink.o.apispace.com/cyudac/api/v1/idioms/SearchIdiomsByPinyin/search"
|
||||
|
||||
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
||||
if (args.isEmpty()) {
|
||||
message.reply("发送`成语解释 <成语>`就能解释这个成语的意思了")
|
||||
return
|
||||
}
|
||||
try {
|
||||
val idiom = args.joinToString(" ").trim()
|
||||
val response = Http.get<IdiomExplainResponse>(
|
||||
apiSpaceUrl,
|
||||
mapOf("name" to idiom, "search_type" to "name"),
|
||||
mapOf("X-APISpace-Token" to configManager.apiSpaceKey)
|
||||
).data.first()
|
||||
val msg = MessageChain.Builder()
|
||||
.addText("成语: ${response.name} 的解释如下")
|
||||
.addNewLine()
|
||||
.addText(response.explanation)
|
||||
.addNewLine(2)
|
||||
.addText(response.provenance)
|
||||
.addNewLine(2)
|
||||
.addText(response.sound)
|
||||
.build()
|
||||
message.reply(msg)
|
||||
} catch (_: Exception) {
|
||||
message.reply("这个词似乎不是一个成语呢~~")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package cn.rtast.fancybot.commands.lookup
|
||||
|
||||
import cn.rtast.fancybot.annotations.CommandDescription
|
||||
import cn.rtast.fancybot.entity.thecat.Cat
|
||||
import cn.rtast.fancybot.util.Http
|
||||
import cn.rtast.fancybot.util.str.encodeToBase64
|
||||
@@ -18,6 +19,7 @@ import cn.rtast.rob.util.BaseCommand
|
||||
import cn.rtast.rob.util.ob.MessageChain
|
||||
import cn.rtast.rob.util.ob.OneBotListener
|
||||
|
||||
@CommandDescription("随机猫猫图")
|
||||
class TheCatCommand : BaseCommand() {
|
||||
override val commandNames = listOf("随机猫咪", "随机猫猫")
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package cn.rtast.fancybot.commands.lookup
|
||||
|
||||
import cn.rtast.fancybot.annotations.CommandDescription
|
||||
import cn.rtast.fancybot.configManager
|
||||
import cn.rtast.fancybot.entity.tianxing.HistoryOfToday
|
||||
import cn.rtast.fancybot.util.Http
|
||||
@@ -19,6 +20,7 @@ import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
@CommandDescription("历史上的今天~~~")
|
||||
class TheHistoryOfTodayCommand : BaseCommand() {
|
||||
override val commandNames = listOf("历史上的今天")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user