Skip to content

Commit

Permalink
fix test and replace all @InternalSimbotAPI to @InternalOneBotAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
ForteScarlet committed Jun 8, 2024
1 parent 40d7af9 commit 80bb524
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

package love.forte.simbot.component.onebot.common

import love.forte.simbot.annotations.InternalSimbotAPI
import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI

/**
* An OneBot object.
*/
@InternalSimbotAPI
@InternalOneBotAPI
public object OneBot

// TODO 一些Opt注解放在这个模块?
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

package love.forte.simbot.component.onebot.v11.common.utils

import love.forte.simbot.annotations.InternalSimbotAPI
import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI
import kotlin.jvm.JvmName

/**
* 得到 `s=640` 的QQ头像。
*
* @param id QQ号
*/
@InternalSimbotAPI
@InternalOneBotAPI
public fun qqAvatar640(id: String): String =
"https://q1.qlogo.cn/g?b=qq&nk=$id&s=640"

Expand All @@ -36,6 +36,6 @@ public fun qqAvatar640(id: String): String =
*
* @param id QQ号
*/
@InternalSimbotAPI
@InternalOneBotAPI
public fun qqAvatar100(id: String): String =
"https://q1.qlogo.cn/g?b=qq&nk=$id&s=100"
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import io.ktor.client.statement.*
import io.ktor.http.*
import io.ktor.http.content.*
import io.ktor.utils.io.charsets.*
import love.forte.simbot.annotations.InternalSimbotAPI
import love.forte.simbot.common.serialization.guessSerializer
import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI
import love.forte.simbot.component.onebot.v11.core.OneBot11
import love.forte.simbot.logger.Logger
import love.forte.simbot.logger.LoggerFactory
Expand All @@ -41,7 +41,7 @@ import kotlin.jvm.JvmSynthetic
/**
* 用于在对 [OneBotApi] 发起请求时或得到想用后输出相关日志日志收集器。
*/
@InternalSimbotAPI
@InternalOneBotAPI
public val ApiLogger: Logger = LoggerFactory.getLogger("love.forte.simbot.component.onebot.v11.core.api.API")

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

package love.forte.simbot.component.onebot.v11.core.bot

import io.ktor.http.Url
import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import love.forte.simbot.annotations.InternalSimbotAPI
import love.forte.simbot.bot.SerializableBotConfiguration
import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI
import love.forte.simbot.component.onebot.v11.core.component.OneBot11Component


Expand All @@ -33,7 +33,7 @@ import love.forte.simbot.component.onebot.v11.core.component.OneBot11Component
*
* @author ForteScarlet
*/
@InternalSimbotAPI
@InternalOneBotAPI
@Serializable
@SerialName(OneBot11Component.ID_VALUE)
public data class OneBotBotSerializableConfiguration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package love.forte.simbot.component.onebot.v11.event

import love.forte.simbot.annotations.InternalSimbotAPI
import love.forte.simbot.common.id.LongID
import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI


/**
Expand Down Expand Up @@ -98,7 +98,7 @@ public interface Event {
*
*/
@Retention(AnnotationRetention.SOURCE)
@InternalSimbotAPI
@InternalOneBotAPI
public annotation class ExpectEventType(val postType: String, val subType: String)

/**
Expand All @@ -109,5 +109,5 @@ public annotation class ExpectEventType(val postType: String, val subType: Strin
* @suppress 用于项目内部代码生成器
*/
@Retention(AnnotationRetention.SOURCE)
@InternalSimbotAPI
@InternalOneBotAPI
public annotation class ExpectEventSubTypeProperty(val value: String, val postType: String, val name: String)
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import love.forte.gradle.common.kotlin.multiplatform.applyTier1
import love.forte.gradle.common.kotlin.multiplatform.applyTier2
import love.forte.gradle.common.kotlin.multiplatform.applyTier3
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi

plugins {
kotlin("multiplatform")
Expand All @@ -38,6 +39,13 @@ kotlin {
explicitApi()
applyDefaultHierarchyTemplate()

@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
optIn.addAll(
"love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI"
)
}

configKotlinJvm()

js(IR) {
Expand All @@ -50,6 +58,7 @@ kotlin {

sourceSets {
commonMain.dependencies {
implementation(project(":simbot-component-onebot-common"))
implementation(libs.simbot.api)
implementation(libs.simbot.common.annotations)
api(libs.kotlinx.coroutines.core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,12 @@
package love.forte.simbot.component.onebot.v11.message

import kotlinx.coroutines.suspendCancellableCoroutine
import love.forte.simbot.annotations.InternalSimbotAPI
import love.forte.simbot.common.id.StringID.Companion.ID
import love.forte.simbot.common.id.literal
import love.forte.simbot.component.onebot.v11.message.segment.OneBotAt
import love.forte.simbot.component.onebot.v11.message.segment.OneBotFace
import love.forte.simbot.component.onebot.v11.message.segment.OneBotImage
import love.forte.simbot.component.onebot.v11.message.segment.OneBotMessageSegment
import love.forte.simbot.component.onebot.v11.message.segment.OneBotMessageSegmentElement
import love.forte.simbot.component.onebot.v11.message.segment.OneBotText
import love.forte.simbot.component.onebot.v11.message.segment.toElement
import love.forte.simbot.message.At
import love.forte.simbot.message.AtAll
import love.forte.simbot.message.Face
import love.forte.simbot.message.Image
import love.forte.simbot.message.Message
import love.forte.simbot.message.Messages
import love.forte.simbot.message.OfflineImage
import love.forte.simbot.component.onebot.common.annotations.InternalOneBotAPI
import love.forte.simbot.component.onebot.v11.message.segment.*
import love.forte.simbot.message.*
import love.forte.simbot.message.OfflineImageResolver.Companion.resolve
import love.forte.simbot.message.OfflineImageValueResolver
import love.forte.simbot.message.RemoteImage
import love.forte.simbot.message.Text
import love.forte.simbot.resource.Resource
import love.forte.simbot.resource.toResource
import love.forte.simbot.resource.toStringResource
Expand All @@ -57,7 +42,7 @@ import kotlin.jvm.JvmName
* | [OneBotFace] | [Face] |
* | 其他 | 使用 [toElement] 转化 |
*/
@InternalSimbotAPI
@InternalOneBotAPI
public fun OneBotMessageSegment.resolveToMessageElement(): Message.Element {
return when (this) {
is OneBotAt -> if (isAll) AtAll else At(data.qq.ID)
Expand All @@ -71,7 +56,7 @@ public fun OneBotMessageSegment.resolveToMessageElement(): Message.Element {
*
* @see resolveToOneBotSegment
*/
@InternalSimbotAPI
@InternalOneBotAPI
public suspend fun Message.resolveToOneBotSegmentList(): List<OneBotMessageSegment> {
return when (this) {
is Message.Element -> resolveToOneBotSegment()
Expand All @@ -85,7 +70,7 @@ public suspend fun Message.resolveToOneBotSegmentList(): List<OneBotMessageSegme
/**
* 将一个 [Message.Element] 转化为用于API请求的 [OneBotMessageSegment]。
*/
@InternalSimbotAPI
@InternalOneBotAPI
public suspend fun Message.Element.resolveToOneBotSegment(): OneBotMessageSegment? {
return when (this) {
// OB组件的 segment 类型,直接使用
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package love.forte.simbot.component.onebot.v11.message
import kotlinx.serialization.json.Json
import kotlinx.serialization.modules.SerializersModule
import kotlinx.serialization.modules.polymorphic
import love.forte.simbot.annotations.InternalSimbotAPI
import love.forte.simbot.common.id.IntID.Companion.ID
import love.forte.simbot.component.onebot.v11.message.segment.OneBotFace
import love.forte.simbot.component.onebot.v11.message.segment.OneBotMessageSegment
Expand All @@ -19,7 +18,6 @@ import kotlin.test.assertEquals
* @author ForteScarlet
*/
class ListElementSerializationTests {
@OptIn(InternalSimbotAPI::class)
@Suppress("VariableNaming")
private val defaultJson = Json {
isLenient = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module simbot.component.onebot11v.message {
requires kotlin.stdlib;
requires simbot.api;
requires simbot.component.onebot.common;
requires static simbot.common.annotations;
requires transitive kotlinx.serialization.core;

Expand Down

0 comments on commit 80bb524

Please sign in to comment.