Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
Update to mirai-core 2.0-M1
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Dec 18, 2020
1 parent 29f3c9c commit e2fb094
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
16 changes: 10 additions & 6 deletions backend/mirai-console/src/command/CommandSender.kt
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public interface CommandSender : CoroutineScope, Permittee {
*/
@JvmStatic
@JvmName("of")
public fun Member.asTempCommandSender(): TempCommandSender = TempCommandSender(this)
public fun NormalMember.asTempCommandSender(): TempCommandSender = TempCommandSender(this)

/**
* 得到 [MemberCommandSender]
Expand All @@ -234,7 +234,7 @@ public interface CommandSender : CoroutineScope, Permittee {
@JvmStatic
@JvmName("of")
public fun Member.asCommandSender(isTemp: Boolean): UserCommandSender {
return if (isTemp) asTempCommandSender() else asMemberCommandSender()
return if (isTemp && this is NormalMember) asTempCommandSender() else asMemberCommandSender()
}

/**
Expand All @@ -253,7 +253,7 @@ public interface CommandSender : CoroutineScope, Permittee {
@JvmName("of")
public fun User.asCommandSender(isTemp: Boolean): UserCommandSender = when (this) {
is Friend -> this.asCommandSender()
is Member -> if (isTemp) TempCommandSender(this) else MemberCommandSender(this)
is Member -> if (isTemp && this is NormalMember) TempCommandSender(this) else MemberCommandSender(this)
else -> error("stub")
}
}
Expand Down Expand Up @@ -545,7 +545,7 @@ public open class MemberCommandSender internal constructor(
* @see TempCommandSenderOnMessage 代表一个 [群员][Member] 主动在临时会话发送消息执行指令
*/
public open class TempCommandSender internal constructor(
public final override val user: Member,
public final override val user: NormalMember,
) : AbstractUserCommandSender(),
GroupAwareCommandSender,
CoroutineScope by user.childScope("TempCommandSender") {
Expand All @@ -560,7 +560,11 @@ public open class TempCommandSender internal constructor(
public override suspend fun sendMessage(message: String): MessageReceipt<Member> = sendMessage(PlainText(message))

@JvmBlockingBridge
public override suspend fun sendMessage(message: Message): MessageReceipt<Member> = user.sendMessage(message)
public override suspend fun sendMessage(message: Message): MessageReceipt<Member> {
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@OptIn(net.mamoe.mirai.utils.MemberDeprecatedApi::class)
return user.sendMessage(message) // just throw this error
}
}

///////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -616,7 +620,7 @@ public class MemberCommandSenderOnMessage internal constructor(
*/
public class TempCommandSenderOnMessage internal constructor(
public override val fromEvent: TempMessageEvent,
) : TempCommandSender(fromEvent.sender),
) : TempCommandSender(fromEvent.sender as NormalMember),
CommandSenderOnMessage<TempMessageEvent>,
MessageEventExtensions<User, Contact> by fromEvent {
public override val subject: Member get() = fromEvent.subject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import java.time.Instant

internal object MiraiConsoleBuildConstants { // auto-filled on build (task :mirai-console:fillBuildConstants)
@JvmStatic
val buildDate: Instant = Instant.ofEpochSecond(1606789540)
const val versionConst: String = "1.1.0"
val buildDate: Instant = Instant.ofEpochSecond(1608309902)
const val versionConst: String = "2.0-M1"

@JvmStatic
val version: SemVersion = SemVersion(versionConst)
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import org.gradle.api.attributes.Attribute

object Versions {
const val core = "2.0-M1-dev-3"
const val console = "2.0-M1-dev-1"
const val core = "2.0-M1"
const val console = "2.0-M1"
const val consoleGraphical = "0.0.7"
const val consoleTerminal = console

Expand All @@ -33,10 +33,10 @@ object Versions {

const val bintray = "1.8.5"

const val blockingBridge = "1.4.1"
const val blockingBridge = "1.5.0"

@Suppress("SpellCheckingInspection")
const val yamlkt = "0.7.4"
const val yamlkt = "0.7.5"

const val intellijGradlePlugin = "0.4.16"
}
Expand Down
2 changes: 1 addition & 1 deletion docs/ConfiguringProjects.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ console 由后端和前端一起工作. 使用时必须选择一个前端.
| 版本类型 | 版本号 |
|:------:|:------------------------------:|
| 稳定 | 1.1.0 |
| 预览 | - |
| 预览 | 2.0-M1 |
| 开发 | [![Version]][Bintray Download] |

## 配置项目
Expand Down
10 changes: 5 additions & 5 deletions tools/gradle-plugin/src/MiraiConsoleExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ import org.gradle.api.publish.maven.MavenPublication
// must be open
public open class MiraiConsoleExtension {
/**
* 为 `true` 时不自动添加 mirai-core 的依赖
* 为 `true` 时不自动添加 mirai-core-api 的依赖
*
* 默认: `false`
*/
public var noCore: Boolean = false
public var noCoreApi: Boolean = false

/**
* 为 `true` 时不自动为 test 模块添加 mirai-core-qqandroid 的依赖.
* 为 `true` 时不自动为 test 模块添加 mirai-core 的依赖.
*
* 默认: `false`
*/
public var noTestCoreQQAndroid: Boolean = false
public var noTestCore: Boolean = false

/**
* 为 `true` 时不自动添加 mirai-console 的依赖.
Expand All @@ -50,7 +50,7 @@ public open class MiraiConsoleExtension {
public var noConsole: Boolean = false

/**
* 自动添加的 mirai-core 和 mirai-core-qqandroid 的版本.
* 自动添加的 mirai-core 和 mirai-core-api 的版本.
*
* 默认: 与本 Gradle 插件编译时的 mirai-core 版本相同. [VersionConstants.CORE_VERSION]
*/
Expand Down
6 changes: 3 additions & 3 deletions tools/gradle-plugin/src/MiraiConsoleGradlePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ public class MiraiConsoleGradlePlugin : Plugin<Project> {

val isJvm = target.platformType == KotlinPlatformType.jvm || target.platformType == KotlinPlatformType.androidJvm

if (!miraiExtension.noCore) compileOnly("net.mamoe:mirai-core:${miraiExtension.coreVersion}")
if (!miraiExtension.noCoreApi) compileOnly("net.mamoe:mirai-core-api:${miraiExtension.coreVersion}")
if (!miraiExtension.noConsole && isJvm) compileOnly("net.mamoe:mirai-console:${miraiExtension.consoleVersion}")

if (sourceSet.name.endsWith("test", ignoreCase = true)) {
if (!miraiExtension.noCore) api("net.mamoe:mirai-core:${miraiExtension.coreVersion}")
if (!miraiExtension.noCoreApi) api("net.mamoe:mirai-core-api:${miraiExtension.coreVersion}")
if (!miraiExtension.noConsole && isJvm) api("net.mamoe:mirai-console:${miraiExtension.consoleVersion}")
if (!miraiExtension.noTestCoreQQAndroid) api("net.mamoe:mirai-core-qqandroid:${miraiExtension.coreVersion}")
if (!miraiExtension.noTestCore) api("net.mamoe:mirai-core:${miraiExtension.coreVersion}")
if (isJvm) {
when (miraiExtension.useTestConsoleFrontEnd) {
MiraiConsoleFrontEndKind.TERMINAL -> api("net.mamoe:mirai-console-terminal:${miraiExtension.consoleVersion}")
Expand Down
4 changes: 2 additions & 2 deletions tools/gradle-plugin/src/VersionConstants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
package net.mamoe.mirai.console.gradle

internal object VersionConstants {
const val CONSOLE_VERSION = "2.0-M1-dev-1" // value is written here automatically during build
const val CORE_VERSION = "2.0-M1-dev-3" // value is written here automatically during build
const val CONSOLE_VERSION = "2.0-M1" // value is written here automatically during build
const val CORE_VERSION = "2.0-M1" // value is written here automatically during build
}

0 comments on commit e2fb094

Please sign in to comment.