Skip to content

Commit b531338

Browse files
committed
feat(core): OneBotBot增加支持获取cookies、credentials、csrfToken的API
1 parent 74df1d0 commit b531338

File tree

2 files changed

+34
-2
lines changed
  • simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot

2 files changed

+34
-2
lines changed

simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBot.kt

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ import love.forte.simbot.component.onebot.common.annotations.OneBotInternalImple
3232
import love.forte.simbot.component.onebot.v11.core.actor.OneBotFriend
3333
import love.forte.simbot.component.onebot.v11.core.actor.OneBotGroup
3434
import love.forte.simbot.component.onebot.v11.core.actor.OneBotMember
35-
import love.forte.simbot.component.onebot.v11.core.api.GetLoginInfoApi
36-
import love.forte.simbot.component.onebot.v11.core.api.GetLoginInfoResult
35+
import love.forte.simbot.component.onebot.v11.core.api.*
3736
import love.forte.simbot.suspendrunner.ST
3837
import kotlin.coroutines.CoroutineContext
3938
import kotlin.jvm.JvmSynthetic
@@ -157,6 +156,30 @@ public interface OneBotBot : Bot {
157156
override val guildRelation: GuildRelation?
158157
get() = null
159158

159+
/**
160+
* 获取 Cookies
161+
* @see GetCookiesApi
162+
* @throws Throwable 任何API请求过程中可能产生的异常
163+
*/
164+
@ST
165+
public suspend fun getCookies(domain: String? = null): GetCookiesResult
166+
167+
/**
168+
* 获取 QQ 相关接口凭证
169+
* @see GetCredentialsApi
170+
* @throws Throwable 任何API请求过程中可能产生的异常
171+
*/
172+
@ST
173+
public suspend fun getCredentials(domain: String? = null): GetCredentialsResult
174+
175+
/**
176+
* 获取 CSRF Token
177+
* @see GetCsrfTokenApi
178+
* @throws Throwable 任何API请求过程中可能产生的异常
179+
*/
180+
@ST
181+
public suspend fun getCsrfToken(): GetCsrfTokenResult
182+
160183

161184
}
162185

simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,15 @@ internal class OneBotBotImpl(
582582
}
583583
}
584584

585+
override suspend fun getCookies(domain: String?): GetCookiesResult =
586+
GetCookiesApi.create(domain).requestDataBy(this)
587+
588+
override suspend fun getCredentials(domain: String?): GetCredentialsResult =
589+
GetCredentialsApi.create(domain).requestDataBy(this)
590+
591+
override suspend fun getCsrfToken(): GetCsrfTokenResult =
592+
GetCsrfTokenApi.create().requestDataBy(this)
593+
585594
override fun toString(): String =
586595
"OneBotBot(uniqueId='$uniqueId', isStarted=$isStarted, isActive=$isActive)"
587596
}

0 commit comments

Comments
 (0)