Skip to content

Commit

Permalink
change the onebot client api
Browse files Browse the repository at this point in the history
  • Loading branch information
alazeprt committed Aug 20, 2024
1 parent 15cb182 commit 449045f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
10 changes: 6 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ subprojects {
}

dependencies {
taboo(files("/libs/OneBot-Client-0.4.1.jar"))
taboo("love.forte.simbot:simbot-core:4.6.0")
taboo("love.forte.simbot.component:simbot-component-onebot-v11-core:1.3.0")
taboo("com.github.SNWCreations:KookBC:0.27.4")
compileOnly("ink.ptms.core:v12004:12004:mapped")
compileOnly("ink.ptms.core:v12004:12004:universal")
compileOnly(kotlin("stdlib"))
runtimeOnly("io.ktor:ktor-client-java:2.3.12")
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

tasks.withType<JavaCompile> {
Expand All @@ -46,7 +48,7 @@ subprojects {

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "11"
freeCompilerArgs = listOf("-Xjvm-default=all")
}
}
Expand Down
31 changes: 31 additions & 0 deletions common/src/main/kotlin/me/regadpole/plumbot/bot/QQBot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ package me.regadpole.plumbot.bot
import cn.evole.onebot.client.OneBotClient
import cn.evole.onebot.client.core.BotConfig
import cn.evole.onebot.sdk.util.MsgUtils
import io.ktor.http.*
import love.forte.simbot.application.Application
import love.forte.simbot.application.launchApplication
import love.forte.simbot.component.onebot.v11.core.bot.OneBotBotConfiguration
import love.forte.simbot.component.onebot.v11.core.bot.firstOneBotBotManager
import love.forte.simbot.component.onebot.v11.core.useOneBot11
import love.forte.simbot.core.application.Simple
import love.forte.simbot.core.application.launchSimpleApplication
import me.regadpole.plumbot.PlumBot
import me.regadpole.plumbot.listener.qq.QQListener
import taboolib.common.platform.function.info
Expand Down Expand Up @@ -34,6 +42,29 @@ class QQBot(private val plugin: PlumBot): Bot {
return this
}

private suspend fun startOnebot() {
val app = launchApplication(Simple) {
useOneBot11()
}

app.configure()
app.join()
}

private suspend fun Application.configure() {
val botManager = botManagers.firstOneBotBotManager()
val bot = botManager.register(
OneBotBotConfiguration().apply {
botUniqueId = "11112222"
apiServerHost = Url("http://127.0.0.1:3000")
eventServerHost = Url("ws://127.0.0.1:3001")
accessToken = null
/// ...
}
)
bot.start()
}

/**
* Stop a bot
*/
Expand Down
Binary file removed libs/OneBot-Client-0.4.1.jar
Binary file not shown.

0 comments on commit 449045f

Please sign in to comment.