All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ly-api.0.0.3-t3.source-code.IBEly.kt Maven / Gradle / Ivy

There is a newer version: 0.0.4-dev-1
Show newest version
package com.elouyi.bely

import com.elouyi.bely.publicapi.PublicApi
import com.elouyi.bely.utils.newInstance
import io.ktor.client.*
import java.util.*
import kotlin.reflect.KClass

val BEly: IBEly get() = _BEly.getInstance()

interface IBEly {

    /**
     * 带浏览器 agent和 json 序列化的 [HttpClient]
     */
    val browserClient: HttpClient

    /**
     * 无需登录的 API
     */
    val publicApi: PublicApi

    val botFactory: BiliBotFactory
}

@Suppress("ClassName","UncheckedCast")
private object _BEly {

    @JvmField
    var instance: IBEly? = null

    fun getInstance(): IBEly {

        return instance ?: run {
            val cl = Class.forName("com.elouyi.bely.BElyImpl").kotlin as KClass
            try {
                cl.newInstance()
            } catch (e: Exception) {
                throw e
            }.also { instance = it }
        }

    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy