diff --git a/src/main/kotlin/JChatGPT.kt b/src/main/kotlin/JChatGPT.kt index 533eee6..a8bad7f 100644 --- a/src/main/kotlin/JChatGPT.kt +++ b/src/main/kotlin/JChatGPT.kt @@ -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 } diff --git a/src/main/kotlin/tools/EpicFreeGame.kt b/src/main/kotlin/tools/EpicFreeGame.kt new file mode 100644 index 0000000..725cb77 --- /dev/null +++ b/src/main/kotlin/tools/EpicFreeGame.kt @@ -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() + } +} \ No newline at end of file