mirror of
https://github.com/jie65535/JChatGPT.git
synced 2025-06-02 17:39:10 +08:00
Add Epic free games query.
Disable ip address query.
This commit is contained in:
parent
caedf97b25
commit
be182215b9
@ -349,8 +349,11 @@ object JChatGPT : KotlinPlugin(
|
||||
// 天气服务
|
||||
WeatherService(),
|
||||
|
||||
// IP所在地查询
|
||||
IpAddressQuery(),
|
||||
// IP所在地查询 暂时取消,几乎不会用到
|
||||
// IpAddressQuery(),
|
||||
|
||||
// Epic 免费游戏
|
||||
EpicFreeGame(),
|
||||
)
|
||||
|
||||
|
||||
@ -401,7 +404,16 @@ object JChatGPT : KotlinPlugin(
|
||||
logger.info("Result=$result")
|
||||
// 过会撤回加载消息
|
||||
if (receipt != null) {
|
||||
launch { delay(3.seconds); receipt.recall() }
|
||||
launch {
|
||||
delay(3.seconds);
|
||||
try {
|
||||
receipt.recall()
|
||||
} catch (e: Throwable) {
|
||||
logger.error("消息撤回失败,调试信息:" +
|
||||
"source.internalIds=${receipt.source.internalIds.joinToString()} " +
|
||||
"source.ids= ${receipt.source.ids.joinToString()}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
23
src/main/kotlin/tools/EpicFreeGame.kt
Normal file
23
src/main/kotlin/tools/EpicFreeGame.kt
Normal file
@ -0,0 +1,23 @@
|
||||
package top.jie65535.mirai.tools
|
||||
|
||||
import com.aallam.openai.api.chat.Tool
|
||||
import com.aallam.openai.api.core.Parameters
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.statement.*
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
class EpicFreeGame : BaseAgent(
|
||||
tool = Tool.function(
|
||||
name = "getEpicFreeGames",
|
||||
description = "可查询Epic免费游戏",
|
||||
parameters = Parameters.Empty
|
||||
)
|
||||
) {
|
||||
// https://docs.60s-api.viki.moe/
|
||||
|
||||
override suspend fun execute(args: JsonObject?): String {
|
||||
// https://docs.60s-api.viki.moe/254044293e0
|
||||
val response = httpClient.get("http://60s-api.viki.moe/v2/epic")
|
||||
return response.bodyAsText()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user