Skip to content

Commit

Permalink
Adapt update
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoii committed Dec 18, 2020
1 parent 8494aa0 commit 2ebc794
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 72 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# build
httpVersion=v1.8.4
httpVersion=v1.9.0
# style guide
kotlin.code.style=official
# config
miraiVersion=1.3.3
miraiConsoleVersion=1.1.0-dev-30
miraiConsoleVersion=1.1.0
kotlin.incremental.multiplatform=true
kotlin.parallel.tasks.in.project=true
# kotlin
kotlinVersion=1.4.20
# kotlin libraries
serializationVersion=1.0.0-RC
coroutinesVersion=1.3.9
atomicFuVersion=0.14.2
serializationVersion=1.0.1
coroutinesVersion=1.4.1
atomicFuVersion=0.14.4
kotlinXIoVersion=0.1.16
coroutinesIoVersion=0.1.16
# utility
Expand Down
39 changes: 8 additions & 31 deletions mirai-api-http/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
id("kotlinx-serialization")
kotlin("jvm")
kotlin("kapt")
id("net.mamoe.mirai-console") version "1.0.0"
}

apply(plugin = "com.github.johnrengelman.shadow")
Expand Down Expand Up @@ -48,27 +47,13 @@ dependencies {
}

kotlin {
sourceSets["main"].apply {
dependencies {

// compileOnly("net.mamoe:mirai-core:$miraiVersion")
// compileOnly("net.mamoe:mirai-core-qqandroid:$miraiVersion")
// compileOnly("net.mamoe:mirai-console:$miraiConsoleVersion")


// compileOnly(kotlin("stdlib-jdk8", kotlinVersion))
// compileOnly(kotlin("stdlib-jdk7", kotlinVersion))
// compileOnly(kotlin("reflect", kotlinVersion))
// api("org.slf4j:slf4j-simple:1.7.26")
}
}

sourceSets["test"].apply {
dependencies {
api("net.mamoe:mirai-core:$miraiVersion")
api("net.mamoe:mirai-console:$miraiConsoleVersion")
api("net.mamoe:mirai-console-terminal:$miraiConsoleVersion")

api(kotlin("stdlib-jdk8", kotlinVersion))
// api(kotlin("stdlib-jdk7", kotlinVersion))
// api(kotlin("reflect", kotlinVersion))
// api(kotlinx("io-jvm"))
api("org.slf4j:slf4j-simple:1.7.26")
}
kotlin.outputDir = file("build/classes/kotlin/jvm/test")
Expand All @@ -81,21 +66,13 @@ kotlin {
languageSettings.useExperimentalAnnotation("kotlin.Experimental")

dependencies {
// compileOnly("net.mamoe:mirai-core:$miraiVersion")
// compileOnly(kotlinx("io-jvm"))
compileOnly("net.mamoe:mirai-core-qqandroid:$miraiVersion")
compileOnly("net.mamoe:mirai-console:$miraiConsoleVersion")
api(kotlinx("serialization-json", serializationVersion))

implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1")
api(ktor("server-cio"))
api(ktor("http-jvm"))
api(ktor("websockets"))
// compileOnly(kotlin("stdlib", kotlinVersion))
// compileOnly(kotlin("serialization", kotlinVersion))

//implementation("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion")
// compileOnly(kotlinx("io"))
// compileOnly(kotlinx("coroutines-io", coroutinesIoVersion))
// compileOnly(kotlinx("coroutines-core", coroutinesVersion))
// compileOnly(kotlinx("serialization-runtime", serializationVersion))
api("org.yaml:snakeyaml:1.25")

implementation(ktor("server-core"))
Expand Down Expand Up @@ -170,4 +147,4 @@ tasks {
args(miraiVersion, miraiConsoleVersion)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ internal typealias CommandSubscriber = suspend (String, Long, Long, List<String>

@AutoService(JvmPlugin::class)
object HttpApiPluginBase : KotlinPlugin(
JvmPluginDescriptionBuilder("net.mamoe.mirai-api-http", "1.8.4")
.name("MiraiApiHttp")
JvmPluginDescriptionBuilder(id = "MiraiApiHttp", version = "1.9.0")
.id("net.mamoe.mirai-api-http")
.author("ryoii")
.info("Mirai HTTP API Server Plugin")
.build()
Expand Down Expand Up @@ -70,16 +70,16 @@ object HttpApiPluginBase : KotlinPlugin(
description: String,
usage: String,
) {
CommandManager.INSTANCE.run {
object : SimpleCommand(HttpApiPluginBase, names.first(), description = description) {
override val usage: String = usage

@Handler
suspend fun onCommand(target: User, message: String) {
// TODO
}
}
}
// CommandManager.INSTANCE.run {
// object : SimpleCommand(HttpApiPluginBase, *names, description = description) {
// override val usage: String = usage
//
// @Handler
// suspend fun onCommand(target: User, message: String) {
// // TODO
// }
// }
// }

/* registerCommand {
this.name = name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import net.mamoe.mirai.console.command.CommandSender
import net.mamoe.mirai.console.command.RawCommand
import net.mamoe.mirai.message.data.MessageChain

internal class RegisterCommand(
description: String,
override val usage: String,
vararg names: String,
) : RawCommand(
HttpApiPluginBase,
names.first(),
description = description
) {
override suspend fun CommandSender.onCommand(args: MessageChain) {
// do nothing
}
}
//internal class RegisterCommand(
// description: String,
// override val usage: String,
// vararg names: String,
//) : RawCommand(
// HttpApiPluginBase,
// names,
// description = description
//) {
// override suspend fun CommandSender.onCommand(args: MessageChain) {
// // do nothing
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import kotlinx.serialization.Serializable
import net.mamoe.mirai.Bot
import net.mamoe.mirai.api.http.HttpApiPluginBase
import net.mamoe.mirai.api.http.SessionManager
import net.mamoe.mirai.api.http.command.RegisterCommand
import net.mamoe.mirai.api.http.data.IllegalParamException
import net.mamoe.mirai.api.http.data.StateCode
import net.mamoe.mirai.api.http.data.common.DTO
Expand All @@ -28,6 +27,7 @@ import net.mamoe.mirai.console.command.CommandExecuteResult
import net.mamoe.mirai.console.command.CommandManager
import net.mamoe.mirai.console.command.CommandManager.INSTANCE.register
import net.mamoe.mirai.console.command.CommandSender
import net.mamoe.mirai.console.command.executeCommand
import net.mamoe.mirai.console.permission.AbstractPermitteeId
import net.mamoe.mirai.console.permission.PermitteeId
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
Expand Down Expand Up @@ -58,8 +58,8 @@ fun Application.commandModule() {
addAll(it.alias)
}

RegisterCommand(it.description, it.usage, *names.toTypedArray()).register(true)
call.respondStateCode(StateCode.Success)
// RegisterCommand(it.description, it.usage, *names.toTypedArray()).register(true)
call.respondStateCode(StateCode(-1, "未支持操作"))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ import net.mamoe.mirai.console.plugin.version
import kotlin.reflect.full.memberProperties

private val mahVersion by lazy {
runCatching {
HttpApiPluginBase.version.toString() // 1.0-M4
}.getOrElse { // 1.0-RC-dev
val desc = HttpApiPluginBase.description
JvmPluginDescription::class.memberProperties.first { it.name == "version" }
.get(desc).toString()
}
val desc = HttpApiPluginBase.description
JvmPluginDescription::class.memberProperties.first { it.name == "version" }
.get(desc).toString()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ package net.mamoe.mirai.api.http.util
import kotlinx.serialization.*
import kotlinx.serialization.json.Json
import kotlinx.serialization.modules.SerializersModule
import kotlinx.serialization.modules.SerializersModuleBuilder
import net.mamoe.mirai.api.http.data.common.*
import kotlin.reflect.KClass

Expand Down

0 comments on commit 2ebc794

Please sign in to comment.