Add Epic free games query.

Disable ip address query.
This commit is contained in:
2025-01-15 10:36:13 +08:00
parent caedf97b25
commit be182215b9
2 changed files with 38 additions and 3 deletions

View File

@ -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
}

View 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()
}
}