Commit 719b5ac7 authored by Him188's avatar Him188

Explicit api mode

parent 0a7ebffd
...@@ -16,8 +16,8 @@ buildscript { ...@@ -16,8 +16,8 @@ buildscript {
dependencies { dependencies {
classpath("com.github.jengelman.gradle.plugins:shadow:5.2.0") classpath("com.github.jengelman.gradle.plugins:shadow:5.2.0")
classpath("com.android.tools.build:gradle:${Versions.Android.androidGradlePlugin}") classpath("com.android.tools.build:gradle:${Versions.Android.androidGradlePlugin}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Kotlin.stdlib}") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Kotlin.compiler}")
classpath("org.jetbrains.kotlin:kotlin-serialization:${Versions.Kotlin.stdlib}") classpath("org.jetbrains.kotlin:kotlin-serialization:${Versions.Kotlin.compiler}")
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:${Versions.Kotlin.atomicFU}") classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:${Versions.Kotlin.atomicFU}")
classpath("org.jetbrains.kotlinx:binary-compatibility-validator:${Versions.Kotlin.binaryValidator}") classpath("org.jetbrains.kotlinx:binary-compatibility-validator:${Versions.Kotlin.binaryValidator}")
} }
......
...@@ -13,6 +13,7 @@ object Versions { ...@@ -13,6 +13,7 @@ object Versions {
} }
object Kotlin { object Kotlin {
const val compiler = "1.4-M3"
const val stdlib = "1.3.72" const val stdlib = "1.3.72"
const val coroutines = "1.3.7" const val coroutines = "1.3.7"
const val atomicFU = "0.14.2" const val atomicFU = "0.14.2"
......
...@@ -21,7 +21,7 @@ kotlin { ...@@ -21,7 +21,7 @@ kotlin {
main { main {
dependencies { dependencies {
api(kotlin("stdlib")) api(kotlin("stdlib", Versions.Kotlin.stdlib))
runtimeOnly(project(":mirai-core-qqandroid")) runtimeOnly(project(":mirai-core-qqandroid"))
compileOnly("net.mamoe:mirai-core-qqandroid:0.38.0") compileOnly("net.mamoe:mirai-core-qqandroid:0.38.0")
} }
...@@ -29,7 +29,7 @@ kotlin { ...@@ -29,7 +29,7 @@ kotlin {
test { test {
dependencies { dependencies {
api(kotlin("stdlib")) api(kotlin("stdlib", Versions.Kotlin.stdlib))
api(kotlin("test")) api(kotlin("test"))
api(kotlin("test-junit")) api(kotlin("test-junit"))
runtimeOnly(project(":mirai-core-qqandroid")) runtimeOnly(project(":mirai-core-qqandroid"))
......
...@@ -4,3 +4,4 @@ kotlin.code.style=official ...@@ -4,3 +4,4 @@ kotlin.code.style=official
kotlin.incremental.multiplatform=true kotlin.incremental.multiplatform=true
kotlin.parallel.tasks.in.project=true kotlin.parallel.tasks.in.project=true
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=512m -Dfile.encoding=UTF-8 org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=512m -Dfile.encoding=UTF-8
#kotlin.mpp.enableGranularSourceSetsMetadata=true
\ No newline at end of file
...@@ -21,14 +21,14 @@ kotlin { ...@@ -21,14 +21,14 @@ kotlin {
main { main {
dependencies { dependencies {
api(kotlin("stdlib")) api(kotlin("stdlib", Versions.Kotlin.stdlib))
api(project(":mirai-core-qqandroid")) api(project(":mirai-core-qqandroid"))
} }
} }
test { test {
dependencies { dependencies {
api(kotlin("stdlib")) api(kotlin("stdlib", Versions.Kotlin.stdlib))
api(kotlin("test")) api(kotlin("test"))
api(kotlin("test-junit")) api(kotlin("test-junit"))
api(project(":mirai-core-qqandroid")) api(project(":mirai-core-qqandroid"))
......
...@@ -36,7 +36,7 @@ kotlin { ...@@ -36,7 +36,7 @@ kotlin {
jvm("jvm") { jvm("jvm") {
} }
sourceSets { sourceSets.apply {
all { all {
languageSettings.enableLanguageFeature("InlineClasses") languageSettings.enableLanguageFeature("InlineClasses")
languageSettings.useExperimentalAnnotation("kotlin.Experimental") languageSettings.useExperimentalAnnotation("kotlin.Experimental")
...@@ -47,6 +47,10 @@ kotlin { ...@@ -47,6 +47,10 @@ kotlin {
languageSettings.useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference") languageSettings.useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
languageSettings.useExperimentalAnnotation("kotlin.time.ExperimentalTime") languageSettings.useExperimentalAnnotation("kotlin.time.ExperimentalTime")
languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts") languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
languageSettings.languageVersion = "1.3"
languageSettings.apiVersion = "1.3"
languageSettings.progressiveMode = true languageSettings.progressiveMode = true
dependencies { dependencies {
...@@ -83,8 +87,8 @@ kotlin { ...@@ -83,8 +87,8 @@ kotlin {
val androidTest by getting { val androidTest by getting {
dependencies { dependencies {
implementation(kotlin("test", Versions.Kotlin.stdlib)) implementation(kotlin("test", Versions.Kotlin.compiler))
implementation(kotlin("test-junit", Versions.Kotlin.stdlib)) implementation(kotlin("test-junit", Versions.Kotlin.compiler))
implementation(kotlin("test-annotations-common")) implementation(kotlin("test-annotations-common"))
implementation(kotlin("test-common")) implementation(kotlin("test-common"))
} }
...@@ -105,8 +109,8 @@ kotlin { ...@@ -105,8 +109,8 @@ kotlin {
val jvmTest by getting { val jvmTest by getting {
dependencies { dependencies {
dependsOn(commonTest) dependsOn(commonTest)
implementation(kotlin("test", Versions.Kotlin.stdlib)) implementation(kotlin("test", Versions.Kotlin.compiler))
implementation(kotlin("test-junit", Versions.Kotlin.stdlib)) implementation(kotlin("test-junit", Versions.Kotlin.compiler))
implementation("org.pcap4j:pcap4j-distribution:1.8.2") implementation("org.pcap4j:pcap4j-distribution:1.8.2")
runtimeOnly(files("build/classes/kotlin/jvm/main")) // classpath is not properly set by IDE runtimeOnly(files("build/classes/kotlin/jvm/main")) // classpath is not properly set by IDE
......
...@@ -14,6 +14,8 @@ description = "Mirai API module" ...@@ -14,6 +14,8 @@ description = "Mirai API module"
val isAndroidSDKAvailable: Boolean by project val isAndroidSDKAvailable: Boolean by project
kotlin { kotlin {
explicitApi()
if (isAndroidSDKAvailable) { if (isAndroidSDKAvailable) {
apply(from = rootProject.file("gradle/android.gradle")) apply(from = rootProject.file("gradle/android.gradle"))
android("android") { android("android") {
...@@ -38,7 +40,7 @@ kotlin { ...@@ -38,7 +40,7 @@ kotlin {
// withJava() // https://youtrack.jetbrains.com/issue/KT-39991 // withJava() // https://youtrack.jetbrains.com/issue/KT-39991
} }
sourceSets { sourceSets.apply {
all { all {
languageSettings.enableLanguageFeature("InlineClasses") languageSettings.enableLanguageFeature("InlineClasses")
languageSettings.useExperimentalAnnotation("kotlin.Experimental") languageSettings.useExperimentalAnnotation("kotlin.Experimental")
...@@ -49,12 +51,16 @@ kotlin { ...@@ -49,12 +51,16 @@ kotlin {
languageSettings.useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference") languageSettings.useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
languageSettings.useExperimentalAnnotation("kotlin.time.ExperimentalTime") languageSettings.useExperimentalAnnotation("kotlin.time.ExperimentalTime")
languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts") languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
languageSettings.languageVersion = "1.3"
languageSettings.apiVersion = "1.3"
languageSettings.progressiveMode = true languageSettings.progressiveMode = true
} }
commonMain { commonMain {
dependencies { dependencies {
api(kotlin("stdlib")) api(kotlin("stdlib", Versions.Kotlin.stdlib))
api(kotlin("serialization")) api(kotlin("serialization"))
api(kotlin("reflect")) api(kotlin("reflect"))
......
...@@ -23,12 +23,12 @@ import kotlin.jvm.JvmSynthetic ...@@ -23,12 +23,12 @@ import kotlin.jvm.JvmSynthetic
* *
* 在 JVM, 请查看 `BotFactoryJvm` * 在 JVM, 请查看 `BotFactoryJvm`
*/ */
expect interface BotFactory { public expect interface BotFactory {
/** /**
* 使用指定的 [配置][configuration] 构造 [Bot] 实例 * 使用指定的 [配置][configuration] 构造 [Bot] 实例
*/ */
@JvmName("newBot") @JvmName("newBot")
fun Bot( public fun Bot(
context: Context, context: Context,
qq: Long, qq: Long,
password: String, password: String,
...@@ -39,7 +39,7 @@ expect interface BotFactory { ...@@ -39,7 +39,7 @@ expect interface BotFactory {
* 使用指定的 [配置][configuration] 构造 [Bot] 实例 * 使用指定的 [配置][configuration] 构造 [Bot] 实例
*/ */
@JvmName("newBot") @JvmName("newBot")
fun Bot( public fun Bot(
context: Context, context: Context,
qq: Long, qq: Long,
passwordMd5: ByteArray, passwordMd5: ByteArray,
...@@ -51,7 +51,7 @@ expect interface BotFactory { ...@@ -51,7 +51,7 @@ expect interface BotFactory {
* 使用指定的 [配置][configuration] 构造 [Bot] 实例 * 使用指定的 [配置][configuration] 构造 [Bot] 实例
*/ */
@JvmSynthetic @JvmSynthetic
inline fun BotFactory.Bot( public inline fun BotFactory.Bot(
context: Context, context: Context,
qq: Long, qq: Long,
password: String, password: String,
...@@ -62,7 +62,7 @@ inline fun BotFactory.Bot( ...@@ -62,7 +62,7 @@ inline fun BotFactory.Bot(
* 使用指定的 [配置][configuration] 构造 [Bot] 实例 * 使用指定的 [配置][configuration] 构造 [Bot] 实例
*/ */
@JvmSynthetic @JvmSynthetic
inline fun BotFactory.Bot( public inline fun BotFactory.Bot(
context: Context, context: Context,
qq: Long, qq: Long,
password: ByteArray, password: ByteArray,
......
...@@ -35,12 +35,12 @@ import kotlin.jvm.JvmSynthetic ...@@ -35,12 +35,12 @@ import kotlin.jvm.JvmSynthetic
* 联系对象, 即可以与 [Bot] 互动的对象. 包含 [用户][User], 和 [群][Group]. * 联系对象, 即可以与 [Bot] 互动的对象. 包含 [用户][User], 和 [群][Group].
*/ */
@Suppress("EXPOSED_SUPER_CLASS") @Suppress("EXPOSED_SUPER_CLASS")
abstract class Contact : ContactOrBot, CoroutineScope, ContactJavaFriendlyAPI { public abstract class Contact : ContactOrBot, CoroutineScope, ContactJavaFriendlyAPI {
/** /**
* 这个联系对象所属 [Bot]. * 这个联系对象所属 [Bot].
*/ */
@WeakRefProperty @WeakRefProperty
abstract val bot: Bot public abstract val bot: Bot
/** /**
* 可以是 QQ 号码或者群号码. * 可以是 QQ 号码或者群号码.
...@@ -48,7 +48,7 @@ abstract class Contact : ContactOrBot, CoroutineScope, ContactJavaFriendlyAPI { ...@@ -48,7 +48,7 @@ abstract class Contact : ContactOrBot, CoroutineScope, ContactJavaFriendlyAPI {
* @see User.id * @see User.id
* @see Group.id * @see Group.id
*/ */
abstract override val id: Long public abstract override val id: Long
/** /**
* 向这个对象发送消息. * 向这个对象发送消息.
...@@ -66,12 +66,12 @@ abstract class Contact : ContactOrBot, CoroutineScope, ContactJavaFriendlyAPI { ...@@ -66,12 +66,12 @@ abstract class Contact : ContactOrBot, CoroutineScope, ContactJavaFriendlyAPI {
* @return 消息回执. 可 [引用回复][MessageReceipt.quote](仅群聊)或 [撤回][MessageReceipt.recall] 这条消息. * @return 消息回执. 可 [引用回复][MessageReceipt.quote](仅群聊)或 [撤回][MessageReceipt.recall] 这条消息.
*/ */
@JvmSynthetic @JvmSynthetic
abstract suspend fun sendMessage(message: Message): MessageReceipt<Contact> public abstract suspend fun sendMessage(message: Message): MessageReceipt<Contact>
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "VIRTUAL_MEMBER_HIDDEN", "OVERRIDE_BY_INLINE") @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "VIRTUAL_MEMBER_HIDDEN", "OVERRIDE_BY_INLINE")
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
@JvmSynthetic @JvmSynthetic
suspend inline fun sendMessage(message: String): MessageReceipt<Contact> { public suspend inline fun sendMessage(message: String): MessageReceipt<Contact> {
return sendMessage(message.toMessage()) return sendMessage(message.toMessage())
} }
...@@ -87,34 +87,34 @@ abstract class Contact : ContactOrBot, CoroutineScope, ContactJavaFriendlyAPI { ...@@ -87,34 +87,34 @@ abstract class Contact : ContactOrBot, CoroutineScope, ContactJavaFriendlyAPI {
* @throws OverFileSizeMaxException 当图片文件过大而被服务器拒绝上传时抛出. (最大大小约为 20 MB, 但 mirai 限制的大小为 30 MB) * @throws OverFileSizeMaxException 当图片文件过大而被服务器拒绝上传时抛出. (最大大小约为 20 MB, 但 mirai 限制的大小为 30 MB)
*/ */
@JvmSynthetic @JvmSynthetic
abstract suspend fun uploadImage(image: ExternalImage): Image public abstract suspend fun uploadImage(image: ExternalImage): Image
final override fun equals(other: Any?): Boolean = super.equals(other) public final override fun equals(other: Any?): Boolean = super.equals(other)
final override fun hashCode(): Int = super.hashCode() public final override fun hashCode(): Int = super.hashCode()
/** /**
* @return "Friend($id)" or "Group($id)" or "Member($id)" * @return "Friend($id)" or "Group($id)" or "Member($id)"
*/ */
abstract override fun toString(): String public abstract override fun toString(): String
} }
/** /**
* @see Bot.recall * @see Bot.recall
*/ */
@JvmSynthetic @JvmSynthetic
suspend inline fun Contact.recall(source: MessageChain) = this.bot.recall(source) public suspend inline fun Contact.recall(source: MessageChain): Unit = this.bot.recall(source)
/** /**
* @see Bot.recall * @see Bot.recall
*/ */
@JvmSynthetic @JvmSynthetic
suspend inline fun Contact.recall(source: MessageSource) = this.bot.recall(source) public suspend inline fun Contact.recall(source: MessageSource): Unit = this.bot.recall(source)
/** /**
* @see Bot.recallIn * @see Bot.recallIn
*/ */
@JvmSynthetic @JvmSynthetic
inline fun Contact.recallIn( public inline fun Contact.recallIn(
message: MessageChain, message: MessageChain,
millis: Long, millis: Long,
coroutineContext: CoroutineContext = EmptyCoroutineContext coroutineContext: CoroutineContext = EmptyCoroutineContext
...@@ -124,7 +124,7 @@ inline fun Contact.recallIn( ...@@ -124,7 +124,7 @@ inline fun Contact.recallIn(
* @see Bot.recallIn * @see Bot.recallIn
*/ */
@JvmSynthetic @JvmSynthetic
inline fun Contact.recallIn( public inline fun Contact.recallIn(
source: MessageSource, source: MessageSource,
millis: Long, millis: Long,
coroutineContext: CoroutineContext = EmptyCoroutineContext coroutineContext: CoroutineContext = EmptyCoroutineContext
......
...@@ -22,24 +22,24 @@ import kotlin.jvm.JvmField ...@@ -22,24 +22,24 @@ import kotlin.jvm.JvmField
* @see ContactList.asSequence * @see ContactList.asSequence
*/ */
@Suppress("unused") @Suppress("unused")
class ContactList<C : Contact> public class ContactList<C : Contact>
internal constructor(@JvmField internal val delegate: LockFreeLinkedList<C>) : Collection<C> { internal constructor(@JvmField internal val delegate: LockFreeLinkedList<C>) : Collection<C> {
operator fun get(id: Long): C = public operator fun get(id: Long): C =
delegate.asSequence().firstOrNull { it.id == id } ?: throw NoSuchElementException("Contact id $id") delegate.asSequence().firstOrNull { it.id == id } ?: throw NoSuchElementException("Contact id $id")
fun getOrNull(id: Long): C? = delegate.getOrNull(id) public fun getOrNull(id: Long): C? = delegate.getOrNull(id)
override val size: Int get() = delegate.size public override val size: Int get() = delegate.size
override operator fun contains(element: C): Boolean = delegate.contains(element) public override operator fun contains(element: C): Boolean = delegate.contains(element)
operator fun contains(id: Long): Boolean = delegate.getOrNull(id) != null public operator fun contains(id: Long): Boolean = delegate.getOrNull(id) != null
override fun containsAll(elements: Collection<C>): Boolean = elements.all { contains(it) } public override fun containsAll(elements: Collection<C>): Boolean = elements.all { contains(it) }
override fun isEmpty(): Boolean = delegate.isEmpty() public override fun isEmpty(): Boolean = delegate.isEmpty()
override fun toString(): String = public override fun toString(): String =
delegate.asSequence().joinToString(separator = ", ", prefix = "ContactList(", postfix = ")") delegate.asSequence().joinToString(separator = ", ", prefix = "ContactList(", postfix = ")")
override fun iterator(): Iterator<C> { public override fun iterator(): Iterator<C> {
return this.delegate.asSequence().iterator() return this.delegate.asSequence().iterator()
} }
} }
...@@ -51,7 +51,7 @@ internal constructor(@JvmField internal val delegate: LockFreeLinkedList<C>) : C ...@@ -51,7 +51,7 @@ internal constructor(@JvmField internal val delegate: LockFreeLinkedList<C>) : C
* [123456, 321654, 123654] * [123456, 321654, 123654]
* ``` * ```
*/ */
val ContactList<*>.idContentString: String public val ContactList<*>.idContentString: String
get() = "[" + buildString { delegate.forEach { append(it.id).append(", ") } }.dropLast( get() = "[" + buildString { delegate.forEach { append(it.id).append(", ") } }.dropLast(
2 2
) + "]" ) + "]"
......
...@@ -19,9 +19,9 @@ import net.mamoe.mirai.Bot ...@@ -19,9 +19,9 @@ import net.mamoe.mirai.Bot
* @see Contact * @see Contact
* @see Bot * @see Bot
*/ */
interface ContactOrBot : CoroutineScope { public interface ContactOrBot : CoroutineScope {
/** /**
* QQ 号或群号. * QQ 号或群号.
*/ */
val id: Long public val id: Long
} }
\ No newline at end of file
...@@ -20,16 +20,16 @@ import kotlin.time.seconds ...@@ -20,16 +20,16 @@ import kotlin.time.seconds
* *
* @see Contact.sendMessage * @see Contact.sendMessage
*/ */
class MessageTooLargeException( public class MessageTooLargeException(
val target: Contact, public val target: Contact,
/** /**
* 原发送消息 * 原发送消息
*/ */
val originalMessage: Message, public val originalMessage: Message,
/** /**
* 经过事件拦截处理后的消息 * 经过事件拦截处理后的消息
*/ */
val messageAfterEvent: Message, public val messageAfterEvent: Message,
exceptionMessage: String exceptionMessage: String
) : RuntimeException(exceptionMessage) ) : RuntimeException(exceptionMessage)
...@@ -38,8 +38,8 @@ class MessageTooLargeException( ...@@ -38,8 +38,8 @@ class MessageTooLargeException(
* *
* @see Group.sendMessage * @see Group.sendMessage
*/ */
class BotIsBeingMutedException( public class BotIsBeingMutedException(
val target: Group public val target: Group
) : RuntimeException("bot is being muted, remaining ${target.botMuteRemaining.seconds.asHumanReadable} seconds") ) : RuntimeException("bot is being muted, remaining ${target.botMuteRemaining.seconds.asHumanReadable} seconds")
inline val BotIsBeingMutedException.botMuteRemaining: Int get() = target.botMuteRemaining public inline val BotIsBeingMutedException.botMuteRemaining: Int get() = target.botMuteRemaining
\ No newline at end of file \ No newline at end of file
...@@ -34,22 +34,22 @@ import kotlin.jvm.JvmSynthetic ...@@ -34,22 +34,22 @@ import kotlin.jvm.JvmSynthetic
* @see FriendMessageEvent * @see FriendMessageEvent
*/ */
@Suppress("DEPRECATION_ERROR") @Suppress("DEPRECATION_ERROR")
abstract class Friend : User(), CoroutineScope { public abstract class Friend : User(), CoroutineScope {
/** /**
* QQ 号码 * QQ 号码
*/ */
abstract override val id: Long public abstract override val id: Long
/** /**
* 昵称 * 昵称
*/ */
abstract override val nick: String public abstract override val nick: String
/** /**
* 头像下载链接 * 头像下载链接
*/ */
override val avatarUrl: String public override val avatarUrl: String
get() = "http://q1.qlogo.cn/g?b=qq&nk=$id&s=640" get() = "http://q1.qlogo.cn/g?b=qq&nk=$id&s=640"
/** /**
......
...@@ -32,7 +32,7 @@ import kotlin.jvm.JvmSynthetic ...@@ -32,7 +32,7 @@ import kotlin.jvm.JvmSynthetic
/** /**
* 群. * 群.
*/ */
abstract class Group : Contact(), CoroutineScope { public abstract class Group : Contact(), CoroutineScope {
/** /**
* 群名称. * 群名称.
* *
...@@ -42,30 +42,30 @@ abstract class Group : Contact(), CoroutineScope { ...@@ -42,30 +42,30 @@ abstract class Group : Contact(), CoroutineScope {
* @see GroupNameChangeEvent 群名片修改事件 * @see GroupNameChangeEvent 群名片修改事件
* @throws PermissionDeniedException 无权限修改时将会抛出异常 * @throws PermissionDeniedException 无权限修改时将会抛出异常
*/ */
abstract var name: String public abstract var name: String
/** /**
* 群设置 * 群设置
*/ */
abstract val settings: GroupSettings public abstract val settings: GroupSettings
/** /**
* 同为 groupCode, 用户看到的群号码. * 同为 groupCode, 用户看到的群号码.
*/ */
abstract override val id: Long public abstract override val id: Long
/** /**
* 群主. * 群主.
* *
* @return 若机器人是群主, 返回 [botAsMember]. 否则返回相应的成员 * @return 若机器人是群主, 返回 [botAsMember]. 否则返回相应的成员
*/ */
abstract val owner: Member public abstract val owner: Member
/** /**
* [Bot] 在群内的 [Member] 实例 * [Bot] 在群内的 [Member] 实例
*/ */
@MiraiExperimentalAPI @MiraiExperimentalAPI
abstract val botAsMember: Member public abstract val botAsMember: Member
/** /**
* 机器人被禁言还剩余多少秒 * 机器人被禁言还剩余多少秒
...@@ -73,7 +73,7 @@ abstract class Group : Contact(), CoroutineScope { ...@@ -73,7 +73,7 @@ abstract class Group : Contact(), CoroutineScope {
* @see BotMuteEvent 机器人被禁言事件 * @see BotMuteEvent 机器人被禁言事件
* @see isBotMuted 判断机器人是否正在被禁言 * @see isBotMuted 判断机器人是否正在被禁言
*/ */
abstract val botMuteRemaining: Int public abstract val botMuteRemaining: Int
/** /**
* 机器人在这个群里的权限 * 机器人在这个群里的权限
...@@ -82,38 +82,38 @@ abstract class Group : Contact(), CoroutineScope { ...@@ -82,38 +82,38 @@ abstract class Group : Contact(), CoroutineScope {
* *
* @see BotGroupPermissionChangeEvent 机器人群员修改 * @see BotGroupPermissionChangeEvent 机器人群员修改
*/ */
abstract val botPermission: MemberPermission public abstract val botPermission: MemberPermission
/** /**
* 群头像下载链接. * 群头像下载链接.
*/ */
val avatarUrl: String public val avatarUrl: String
get() = "https://p.qlogo.cn/gh/$id/${id}/640" get() = "https://p.qlogo.cn/gh/$id/${id}/640"
/** /**
* 群成员列表, 不含机器人自己, 含群主. * 群成员列表, 不含机器人自己, 含群主.
* 在 [Group] 实例创建的时候查询一次. 并与事件同步事件更新 * 在 [Group] 实例创建的时候查询一次. 并与事件同步事件更新
*/ */
abstract val members: ContactList<Member> public abstract val members: ContactList<Member>
/** /**
* 获取群成员实例. 不存在时抛出 [kotlin.NoSuchElementException] * 获取群成员实例. 不存在时抛出 [kotlin.NoSuchElementException]
* 当 [id] 为 [Bot.id] 时返回 [botAsMember] * 当 [id] 为 [Bot.id] 时返回 [botAsMember]
*/ */
@Throws(NoSuchElementException::class) @Throws(NoSuchElementException::class)
abstract operator fun get(id: Long): Member public abstract operator fun get(id: Long): Member
/** /**
* 获取群成员实例, 不存在则 null * 获取群成员实例, 不存在则 null
* 当 [id] 为 [Bot.id] 时返回 [botAsMember] * 当 [id] 为 [Bot.id] 时返回 [botAsMember]
*/ */
abstract fun getOrNull(id: Long): Member? public abstract fun getOrNull(id: Long): Member?
/** /**
* 检查此 id 的群成员是否存在 * 检查此 id 的群成员是否存在
* 当 [id] 为 [Bot.id] 时返回 `true` * 当 [id] 为 [Bot.id] 时返回 `true`
*/ */
abstract operator fun contains(id: Long): Boolean public abstract operator fun contains(id: Long): Boolean
/** /**
...@@ -122,7 +122,7 @@ abstract class Group : Contact(), CoroutineScope { ...@@ -122,7 +122,7 @@ abstract class Group : Contact(), CoroutineScope {
* @return 退出成功时 true; 已经退出时 false * @return 退出成功时 true; 已经退出时 false
*/ */
@JvmSynthetic @JvmSynthetic
abstract suspend fun quit(): Boolean public abstract suspend fun quit(): Boolean
/** /**
* 构造一个 [Member]. * 构造一个 [Member].
...@@ -130,7 +130,7 @@ abstract class Group : Contact(), CoroutineScope { ...@@ -130,7 +130,7 @@ abstract class Group : Contact(), CoroutineScope {
*/ */
@LowLevelAPI @LowLevelAPI
@MiraiExperimentalAPI("dangerous") @MiraiExperimentalAPI("dangerous")
abstract fun newMember(memberInfo: MemberInfo): Member public abstract fun newMember(memberInfo: MemberInfo): Member
/** /**
* 向这个对象发送消息. * 向这个对象发送消息.
...@@ -148,7 +148,7 @@ abstract class Group : Contact(), CoroutineScope { ...@@ -148,7 +148,7 @@ abstract class Group : Contact(), CoroutineScope {
* @return 消息回执. 可进行撤回 ([MessageReceipt.recall]) * @return 消息回执. 可进行撤回 ([MessageReceipt.recall])
*/ */
@JvmSynthetic @JvmSynthetic
abstract override suspend fun sendMessage(message: Message): MessageReceipt<Group> public abstract override suspend fun sendMessage(message: Message): MessageReceipt<Group>
/** /**
* @see sendMessage * @see sendMessage
...@@ -156,7 +156,7 @@ abstract class Group : Contact(), CoroutineScope { ...@@ -156,7 +156,7 @@ abstract class Group : Contact(), CoroutineScope {
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "VIRTUAL_MEMBER_HIDDEN", "OVERRIDE_BY_INLINE") @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "VIRTUAL_MEMBER_HIDDEN", "OVERRIDE_BY_INLINE")
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
@JvmSynthetic @JvmSynthetic
suspend inline fun sendMessage(message: String): MessageReceipt<Group> { public suspend inline fun sendMessage(message: String): MessageReceipt<Group> {
return sendMessage(message.toMessage()) return sendMessage(message.toMessage())
} }
...@@ -172,16 +172,16 @@ abstract class Group : Contact(), CoroutineScope { ...@@ -172,16 +172,16 @@ abstract class Group : Contact(), CoroutineScope {
* @throws OverFileSizeMaxException 当图片文件过大而被服务器拒绝上传时. (最大大小约为 20 MB) * @throws OverFileSizeMaxException 当图片文件过大而被服务器拒绝上传时. (最大大小约为 20 MB)
*/ */
@JvmSynthetic @JvmSynthetic
abstract override suspend fun uploadImage(image: ExternalImage): Image public abstract override suspend fun uploadImage(image: ExternalImage): Image
companion object { public companion object {
/** /**
* 使用 groupCode 计算 groupUin. 这两个值仅在 mirai 内部协议区分, 一般人使用时无需在意. * 使用 groupCode 计算 groupUin. 这两个值仅在 mirai 内部协议区分, 一般人使用时无需在意.
* @suppress internal api * @suppress internal api
*/ */
@MiraiExperimentalAPI @MiraiExperimentalAPI
@JvmStatic @JvmStatic
fun calculateGroupUinByGroupCode(groupCode: Long): Long = public fun calculateGroupUinByGroupCode(groupCode: Long): Long =
CommonGroupCalculations.calculateGroupUinByGroupCode(groupCode) CommonGroupCalculations.calculateGroupUinByGroupCode(groupCode)
/** /**
...@@ -190,7 +190,7 @@ abstract class Group : Contact(), CoroutineScope { ...@@ -190,7 +190,7 @@ abstract class Group : Contact(), CoroutineScope {
*/ */
@MiraiExperimentalAPI @MiraiExperimentalAPI
@JvmStatic @JvmStatic
fun calculateGroupCodeByGroupUin(groupUin: Long): Long = public fun calculateGroupCodeByGroupUin(groupUin: Long): Long =
CommonGroupCalculations.calculateGroupCodeByGroupUin(groupUin) CommonGroupCalculations.calculateGroupCodeByGroupUin(groupUin)
} }
...@@ -200,7 +200,7 @@ abstract class Group : Contact(), CoroutineScope { ...@@ -200,7 +200,7 @@ abstract class Group : Contact(), CoroutineScope {
@Suppress("FunctionName") @Suppress("FunctionName")
@JvmName("quit") @JvmName("quit")
@JavaFriendlyAPI @JavaFriendlyAPI
fun __quitBlockingForJava__(): Boolean = runBlocking { quit() } public fun __quitBlockingForJava__(): Boolean = runBlocking { quit() }
} }
/** /**
...@@ -208,7 +208,7 @@ abstract class Group : Contact(), CoroutineScope { ...@@ -208,7 +208,7 @@ abstract class Group : Contact(), CoroutineScope {
* *
* @see Group.settings 获取群设置 * @see Group.settings 获取群设置
*/ */
interface GroupSettings { public interface GroupSettings {
/** /**
* 入群公告, 没有时为空字符串. * 入群公告, 没有时为空字符串.
* *
...@@ -217,7 +217,7 @@ interface GroupSettings { ...@@ -217,7 +217,7 @@ interface GroupSettings {
* @see GroupEntranceAnnouncementChangeEvent * @see GroupEntranceAnnouncementChangeEvent
* @throws PermissionDeniedException 无权限修改时将会抛出异常 * @throws PermissionDeniedException 无权限修改时将会抛出异常
*/ */
var entranceAnnouncement: String public var entranceAnnouncement: String
/** /**
* 全体禁言状态. `true` 为开启. * 全体禁言状态. `true` 为开启.
...@@ -227,7 +227,7 @@ interface GroupSettings { ...@@ -227,7 +227,7 @@ interface GroupSettings {
* @see GroupMuteAllEvent * @see GroupMuteAllEvent
* @throws PermissionDeniedException 无权限修改时将会抛出异常 * @throws PermissionDeniedException 无权限修改时将会抛出异常
*/ */
var isMuteAll: Boolean public var isMuteAll: Boolean
/** /**
* 坦白说状态. `true` 为允许. * 坦白说状态. `true` 为允许.
...@@ -239,7 +239,7 @@ interface GroupSettings { ...@@ -239,7 +239,7 @@ interface GroupSettings {
*/ */
@PlannedRemoval("1.3.0") @PlannedRemoval("1.3.0")
@Deprecated("mirai 将不再支持此用例较少的设置", level = DeprecationLevel.WARNING) @Deprecated("mirai 将不再支持此用例较少的设置", level = DeprecationLevel.WARNING)
var isConfessTalkEnabled: Boolean public var isConfessTalkEnabled: Boolean
/** /**
* 允许群员邀请好友入群的状态. `true` 为允许 * 允许群员邀请好友入群的状态. `true` 为允许
...@@ -249,18 +249,18 @@ interface GroupSettings { ...@@ -249,18 +249,18 @@ interface GroupSettings {
* @see GroupAllowMemberInviteEvent * @see GroupAllowMemberInviteEvent
* @throws PermissionDeniedException 无权限修改时将会抛出异常 * @throws PermissionDeniedException 无权限修改时将会抛出异常
*/ */
var isAllowMemberInvite: Boolean public var isAllowMemberInvite: Boolean
/** /**
* 自动加群审批 * 自动加群审批
*/ */
@MiraiExperimentalAPI @MiraiExperimentalAPI
val isAutoApproveEnabled: Boolean public val isAutoApproveEnabled: Boolean
/** /**
* 匿名聊天 * 匿名聊天
*/ */
val isAnonymousChatEnabled: Boolean public val isAnonymousChatEnabled: Boolean
} }
...@@ -269,7 +269,7 @@ interface GroupSettings { ...@@ -269,7 +269,7 @@ interface GroupSettings {
* *
* @see Group.botMuteRemaining 剩余禁言时间 * @see Group.botMuteRemaining 剩余禁言时间
*/ */
inline val Group.isBotMuted: Boolean get() = this.botMuteRemaining != 0 public inline val Group.isBotMuted: Boolean get() = this.botMuteRemaining != 0
internal object CommonGroupCalculations { internal object CommonGroupCalculations {
......
...@@ -20,9 +20,6 @@ import net.mamoe.mirai.message.data.Message ...@@ -20,9 +20,6 @@ import net.mamoe.mirai.message.data.Message
import net.mamoe.mirai.message.data.isContentEmpty import net.mamoe.mirai.message.data.isContentEmpty
import net.mamoe.mirai.message.data.toMessage import net.mamoe.mirai.message.data.toMessage
import net.mamoe.mirai.message.recall import net.mamoe.mirai.message.recall
import net.mamoe.mirai.utils.hoursToSeconds
import net.mamoe.mirai.utils.daysToSeconds
import net.mamoe.mirai.utils.minutesToSeconds
import net.mamoe.mirai.utils.WeakRefProperty import net.mamoe.mirai.utils.WeakRefProperty
import kotlin.jvm.JvmSynthetic import kotlin.jvm.JvmSynthetic
import kotlin.time.Duration import kotlin.time.Duration
...@@ -39,19 +36,19 @@ import kotlin.time.ExperimentalTime ...@@ -39,19 +36,19 @@ import kotlin.time.ExperimentalTime
*/ */
@Suppress("INAPPLICABLE_JVM_NAME", "EXPOSED_SUPER_CLASS") @Suppress("INAPPLICABLE_JVM_NAME", "EXPOSED_SUPER_CLASS")
@OptIn(JavaFriendlyAPI::class) @OptIn(JavaFriendlyAPI::class)
abstract class Member : MemberJavaFriendlyAPI, User() { public abstract class Member : MemberJavaFriendlyAPI, User() {
/** /**
* 所在的群. * 所在的群.
*/ */
@WeakRefProperty @WeakRefProperty
abstract val group: Group public abstract val group: Group
/** /**
* 成员的权限, 动态更新. * 成员的权限, 动态更新.
* *
* @see MemberPermissionChangeEvent 权限变更事件. 由群主或机器人的操作触发. * @see MemberPermissionChangeEvent 权限变更事件. 由群主或机器人的操作触发.
*/ */
abstract val permission: MemberPermission public abstract val permission: MemberPermission
/** /**
* 群名片. 可能为空. * 群名片. 可能为空.
...@@ -65,7 +62,7 @@ abstract class Member : MemberJavaFriendlyAPI, User() { ...@@ -65,7 +62,7 @@ abstract class Member : MemberJavaFriendlyAPI, User() {
* @see MemberCardChangeEvent 群名片被管理员, 自己或 [Bot] 改动事件. 修改时也会触发此事件. * @see MemberCardChangeEvent 群名片被管理员, 自己或 [Bot] 改动事件. 修改时也会触发此事件.
* @throws PermissionDeniedException 无权限修改时 * @throws PermissionDeniedException 无权限修改时
*/ */
abstract var nameCard: String public abstract var nameCard: String
/** /**
* 群头衔. * 群头衔.
...@@ -77,7 +74,7 @@ abstract class Member : MemberJavaFriendlyAPI, User() { ...@@ -77,7 +74,7 @@ abstract class Member : MemberJavaFriendlyAPI, User() {
* @see MemberSpecialTitleChangeEvent 群名片被管理员, 自己或 [Bot] 改动事件. 修改时也会触发此事件. * @see MemberSpecialTitleChangeEvent 群名片被管理员, 自己或 [Bot] 改动事件. 修改时也会触发此事件.
* @throws PermissionDeniedException 无权限修改时 * @throws PermissionDeniedException 无权限修改时
*/ */
abstract var specialTitle: String public abstract var specialTitle: String
/** /**
* 被禁言剩余时长. 单位为秒. * 被禁言剩余时长. 单位为秒.
...@@ -86,7 +83,7 @@ abstract class Member : MemberJavaFriendlyAPI, User() { ...@@ -86,7 +83,7 @@ abstract class Member : MemberJavaFriendlyAPI, User() {
* @see mute 设置禁言 * @see mute 设置禁言
* @see unmute 取消禁言 * @see unmute 取消禁言
*/ */
abstract val muteTimeRemaining: Int public abstract val muteTimeRemaining: Int
/** /**
* 禁言. * 禁言.
...@@ -111,7 +108,7 @@ abstract class Member : MemberJavaFriendlyAPI, User() { ...@@ -111,7 +108,7 @@ abstract class Member : MemberJavaFriendlyAPI, User() {
* @throws PermissionDeniedException 无权限修改时抛出 * @throws PermissionDeniedException 无权限修改时抛出
*/ */
@JvmSynthetic @JvmSynthetic
abstract suspend fun mute(durationSeconds: Int) public abstract suspend fun mute(durationSeconds: Int)
/** /**
* 解除禁言. * 解除禁言.
...@@ -125,7 +122,7 @@ abstract class Member : MemberJavaFriendlyAPI, User() { ...@@ -125,7 +122,7 @@ abstract class Member : MemberJavaFriendlyAPI, User() {
* @throws PermissionDeniedException 无权限修改时抛出 * @throws PermissionDeniedException 无权限修改时抛出
*/ */
@JvmSynthetic @JvmSynthetic
abstract suspend fun unmute() public abstract suspend fun unmute()
/** /**
* 踢出该成员. * 踢出该成员.
...@@ -136,7 +133,7 @@ abstract class Member : MemberJavaFriendlyAPI, User() { ...@@ -136,7 +133,7 @@ abstract class Member : MemberJavaFriendlyAPI, User() {
* @throws PermissionDeniedException 无权限修改时 * @throws PermissionDeniedException 无权限修改时
*/ */
@JvmSynthetic @JvmSynthetic
abstract suspend fun kick(message: String = "") public abstract suspend fun kick(message: String = "")
/** /**
* 向群成员发送消息. * 向群成员发送消息.
...@@ -158,7 +155,7 @@ abstract class Member : MemberJavaFriendlyAPI, User() { ...@@ -158,7 +155,7 @@ abstract class Member : MemberJavaFriendlyAPI, User() {
* @return 消息回执. 可进行撤回 ([MessageReceipt.recall]) * @return 消息回执. 可进行撤回 ([MessageReceipt.recall])
*/ */
@JvmSynthetic @JvmSynthetic
abstract override suspend fun sendMessage(message: Message): MessageReceipt<Member> public abstract override suspend fun sendMessage(message: Message): MessageReceipt<Member>
/** /**
* @see sendMessage * @see sendMessage
...@@ -166,11 +163,11 @@ abstract class Member : MemberJavaFriendlyAPI, User() { ...@@ -166,11 +163,11 @@ abstract class Member : MemberJavaFriendlyAPI, User() {
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "VIRTUAL_MEMBER_HIDDEN", "OVERRIDE_BY_INLINE") @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "VIRTUAL_MEMBER_HIDDEN", "OVERRIDE_BY_INLINE")
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
@JvmSynthetic @JvmSynthetic
suspend inline fun sendMessage(message: String): MessageReceipt<Member> { public suspend inline fun sendMessage(message: String): MessageReceipt<Member> {
return sendMessage(message.toMessage()) return sendMessage(message.toMessage())
} }
final override fun toString(): String = "Member($id)" public final override fun toString(): String = "Member($id)"
} }
/** /**
...@@ -178,23 +175,23 @@ abstract class Member : MemberJavaFriendlyAPI, User() { ...@@ -178,23 +175,23 @@ abstract class Member : MemberJavaFriendlyAPI, User() {
* *
* @throws IllegalStateException 当此成员不是好友时抛出 * @throws IllegalStateException 当此成员不是好友时抛出
*/ */
fun Member.asFriend(): Friend = this.bot.getFriendOrNull(this.id) ?: error("$this is not a friend") public fun Member.asFriend(): Friend = this.bot.getFriendOrNull(this.id) ?: error("$this is not a friend")
/** /**
* 得到此成员作为好友的对象, 当此成员不是好友时返回 `null` * 得到此成员作为好友的对象, 当此成员不是好友时返回 `null`
*/ */
fun Member.asFriendOrNull(): Friend? = this.bot.getFriendOrNull(this.id) public fun Member.asFriendOrNull(): Friend? = this.bot.getFriendOrNull(this.id)
/** /**
* 判断此成员是否为好友 * 判断此成员是否为好友
*/ */
inline val Member.isFriend: Boolean public inline val Member.isFriend: Boolean
get() = this.bot.friends.contains(this.id) get() = this.bot.friends.contains(this.id)
/** /**
* 如果此成员是好友, 则执行 [block] 并返回其返回值. 否则返回 `null` * 如果此成员是好友, 则执行 [block] 并返回其返回值. 否则返回 `null`
*/ */
inline fun <R> Member.takeIfIsFriend(block: (Friend) -> R): R? { public inline fun <R> Member.takeIfIsFriend(block: (Friend) -> R): R? {
return this.asFriendOrNull()?.let(block) return this.asFriendOrNull()?.let(block)
} }
...@@ -203,7 +200,7 @@ inline fun <R> Member.takeIfIsFriend(block: (Friend) -> R): R? { ...@@ -203,7 +200,7 @@ inline fun <R> Member.takeIfIsFriend(block: (Friend) -> R): R? {
* *
* 若 [群名片][Member.nameCard] 不为空则返回群名片, 为空则返回 [User.nick] * 若 [群名片][Member.nameCard] 不为空则返回群名片, 为空则返回 [User.nick]
*/ */
val Member.nameCardOrNick: String get() = this.nameCard.takeIf { it.isNotEmpty() } ?: this.nick public val Member.nameCardOrNick: String get() = this.nameCard.takeIf { it.isNotEmpty() } ?: this.nick
/** /**
* 获取非空群名片或昵称. * 获取非空群名片或昵称.
...@@ -212,7 +209,7 @@ val Member.nameCardOrNick: String get() = this.nameCard.takeIf { it.isNotEmpty() ...@@ -212,7 +209,7 @@ val Member.nameCardOrNick: String get() = this.nameCard.takeIf { it.isNotEmpty()
* *
* 否则返回 [Member.nick] * 否则返回 [Member.nick]
*/ */
val User.nameCardOrNick: String public val User.nameCardOrNick: String
get() = when (this) { get() = when (this) {
is Member -> this.nameCardOrNick is Member -> this.nameCardOrNick
else -> this.nick else -> this.nick
...@@ -221,14 +218,14 @@ val User.nameCardOrNick: String ...@@ -221,14 +218,14 @@ val User.nameCardOrNick: String
/** /**
* 判断群成员是否处于禁言状态. * 判断群成员是否处于禁言状态.
*/ */
val Member.isMuted: Boolean public val Member.isMuted: Boolean
get() = muteTimeRemaining != 0 && muteTimeRemaining != 0xFFFFFFFF.toInt() get() = muteTimeRemaining != 0 && muteTimeRemaining != 0xFFFFFFFF.toInt()
/** /**
* @see Member.mute * @see Member.mute
*/ */
@ExperimentalTime @ExperimentalTime
suspend inline fun Member.mute(duration: Duration) { public suspend inline fun Member.mute(duration: Duration) {
require(duration.inDays <= 30) { "duration must be at most 1 month" } require(duration.inDays <= 30) { "duration must be at most 1 month" }
require(duration.inSeconds > 0) { "duration must be greater than 0 second" } require(duration.inSeconds > 0) { "duration must be greater than 0 second" }
this.mute(duration.inSeconds.toInt()) this.mute(duration.inSeconds.toInt())
...@@ -237,4 +234,4 @@ suspend inline fun Member.mute(duration: Duration) { ...@@ -237,4 +234,4 @@ suspend inline fun Member.mute(duration: Duration) {
/** /**
* @see Member.mute * @see Member.mute
*/ */
suspend inline fun Member.mute(durationSeconds: Long) = this.mute(durationSeconds.toInt()) public suspend inline fun Member.mute(durationSeconds: Long): Unit = this.mute(durationSeconds.toInt())
\ No newline at end of file \ No newline at end of file
...@@ -26,7 +26,7 @@ import kotlin.internal.InlineOnly ...@@ -26,7 +26,7 @@ import kotlin.internal.InlineOnly
* @see Member.isOperator 对 [Member] 的扩展函数, 判断此成员是否为管理员或群主 * @see Member.isOperator 对 [Member] 的扩展函数, 判断此成员是否为管理员或群主
* @see Member.isAdministrator 对 [Member] 的扩展函数, 判断此成员是否为管理员 * @see Member.isAdministrator 对 [Member] 的扩展函数, 判断此成员是否为管理员
*/ */
enum class MemberPermission : Comparable<MemberPermission> { public enum class MemberPermission : Comparable<MemberPermission> {
/** /**
* 一般群成员 * 一般群成员
*/ */
...@@ -45,7 +45,7 @@ enum class MemberPermission : Comparable<MemberPermission> { ...@@ -45,7 +45,7 @@ enum class MemberPermission : Comparable<MemberPermission> {
/** /**
* 权限等级. [OWNER] 为 2, [ADMINISTRATOR] 为 1, [MEMBER] 为 0 * 权限等级. [OWNER] 为 2, [ADMINISTRATOR] 为 1, [MEMBER] 为 0
*/ */
val level: Int public val level: Int
get() = ordinal get() = ordinal
} }
...@@ -53,44 +53,44 @@ enum class MemberPermission : Comparable<MemberPermission> { ...@@ -53,44 +53,44 @@ enum class MemberPermission : Comparable<MemberPermission> {
* 判断权限是否为群主 * 判断权限是否为群主
*/ */
@InlineOnly @InlineOnly
inline fun MemberPermission.isOwner(): Boolean = this == MemberPermission.OWNER public inline fun MemberPermission.isOwner(): Boolean = this == MemberPermission.OWNER
/** /**
* 判断权限是否为管理员 * 判断权限是否为管理员
*/ */
@InlineOnly @InlineOnly
inline fun MemberPermission.isAdministrator(): Boolean = this == MemberPermission.ADMINISTRATOR public inline fun MemberPermission.isAdministrator(): Boolean = this == MemberPermission.ADMINISTRATOR
/** /**
* 判断权限是否为管理员或群主 * 判断权限是否为管理员或群主
*/ */
@InlineOnly @InlineOnly
inline fun MemberPermission.isOperator(): Boolean = isAdministrator() || isOwner() public inline fun MemberPermission.isOperator(): Boolean = isAdministrator() || isOwner()
/** /**
* 判断权限是否为群主 * 判断权限是否为群主
*/ */
inline fun Member.isOwner(): Boolean = this.permission.isOwner() public inline fun Member.isOwner(): Boolean = this.permission.isOwner()
/** /**
* 判断权限是否为管理员 * 判断权限是否为管理员
*/ */
inline fun Member.isAdministrator(): Boolean = this.permission.isAdministrator() public inline fun Member.isAdministrator(): Boolean = this.permission.isAdministrator()
/** /**
* 判断权限是否为管理员或群主 * 判断权限是否为管理员或群主
*/ */
inline fun Member.isOperator(): Boolean = this.permission.isOperator() public inline fun Member.isOperator(): Boolean = this.permission.isOperator()
/** /**
* 权限不足 * 权限不足
*/ */
@Suppress("unused") @Suppress("unused")
class PermissionDeniedException : IllegalStateException { public class PermissionDeniedException : IllegalStateException {
constructor() : super("Permission denied") public constructor() : super("Permission denied")
constructor(message: String?) : super(message) public constructor(message: String?) : super(message)
} }
/** /**
...@@ -98,7 +98,7 @@ class PermissionDeniedException : IllegalStateException { ...@@ -98,7 +98,7 @@ class PermissionDeniedException : IllegalStateException {
* *
* @throws PermissionDeniedException * @throws PermissionDeniedException
*/ */
inline fun Group.checkBotPermission( public inline fun Group.checkBotPermission(
required: MemberPermission, required: MemberPermission,
crossinline lazyMessage: () -> String = { crossinline lazyMessage: () -> String = {
"Permission denied: required $required, got actual $botPermission for $bot in group $id" "Permission denied: required $required, got actual $botPermission for $bot in group $id"
...@@ -115,8 +115,8 @@ inline fun Group.checkBotPermission( ...@@ -115,8 +115,8 @@ inline fun Group.checkBotPermission(
* @throws PermissionDeniedException * @throws PermissionDeniedException
*/ */
@Deprecated("use checkBotPermission", ReplaceWith("checkBotPermission(MemberPermission.ADMINISTRATOR)")) @Deprecated("use checkBotPermission", ReplaceWith("checkBotPermission(MemberPermission.ADMINISTRATOR)"))
inline fun Group.checkBotPermissionOperator( public inline fun Group.checkBotPermissionOperator(
crossinline lazyMessage: () -> String = { crossinline lazyMessage: () -> String = {
"Permission denied: required ${MemberPermission.ADMINISTRATOR} or ${MemberPermission.OWNER}, got actual $botPermission for $bot in group $id" "Permission denied: required ${MemberPermission.ADMINISTRATOR} or ${MemberPermission.OWNER}, got actual $botPermission for $bot in group $id"
} }
) = checkBotPermission(MemberPermission.ADMINISTRATOR, lazyMessage) ): Unit = checkBotPermission(MemberPermission.ADMINISTRATOR, lazyMessage)
\ No newline at end of file \ No newline at end of file
...@@ -32,21 +32,21 @@ import kotlin.jvm.JvmSynthetic ...@@ -32,21 +32,21 @@ import kotlin.jvm.JvmSynthetic
* *
* 对于同一个 [Bot] 任何一个人的 [User] 实例都是单一的. * 对于同一个 [Bot] 任何一个人的 [User] 实例都是单一的.
*/ */
abstract class User : Contact(), CoroutineScope { public abstract class User : Contact(), CoroutineScope {
/** /**
* QQ 号码 * QQ 号码
*/ */
abstract override val id: Long public abstract override val id: Long
/** /**
* 昵称 * 昵称
*/ */
abstract val nick: String public abstract val nick: String
/** /**
* 头像下载链接 * 头像下载链接
*/ */
open val avatarUrl: String public open val avatarUrl: String
get() = "http://q1.qlogo.cn/g?b=qq&nk=$id&s=640" get() = "http://q1.qlogo.cn/g?b=qq&nk=$id&s=640"
/** /**
...@@ -65,7 +65,7 @@ abstract class User : Contact(), CoroutineScope { ...@@ -65,7 +65,7 @@ abstract class User : Contact(), CoroutineScope {
* @return 消息回执. 可进行撤回 ([MessageReceipt.recall]) * @return 消息回执. 可进行撤回 ([MessageReceipt.recall])
*/ */
@JvmSynthetic @JvmSynthetic
abstract override suspend fun sendMessage(message: Message): MessageReceipt<User> public abstract override suspend fun sendMessage(message: Message): MessageReceipt<User>
/** /**
* @see sendMessage * @see sendMessage
...@@ -73,7 +73,7 @@ abstract class User : Contact(), CoroutineScope { ...@@ -73,7 +73,7 @@ abstract class User : Contact(), CoroutineScope {
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "VIRTUAL_MEMBER_HIDDEN", "OVERRIDE_BY_INLINE") @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "VIRTUAL_MEMBER_HIDDEN", "OVERRIDE_BY_INLINE")
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
@JvmSynthetic @JvmSynthetic
suspend inline fun sendMessage(message: String): MessageReceipt<User> { public suspend inline fun sendMessage(message: String): MessageReceipt<User> {
return sendMessage(message.toMessage()) return sendMessage(message.toMessage())
} }
...@@ -89,7 +89,7 @@ abstract class User : Contact(), CoroutineScope { ...@@ -89,7 +89,7 @@ abstract class User : Contact(), CoroutineScope {
* @throws OverFileSizeMaxException 当图片文件过大而被服务器拒绝上传时. (最大大小约为 20 MB) * @throws OverFileSizeMaxException 当图片文件过大而被服务器拒绝上传时. (最大大小约为 20 MB)
*/ */
@JvmSynthetic @JvmSynthetic
abstract override suspend fun uploadImage(image: ExternalImage): Image public abstract override suspend fun uploadImage(image: ExternalImage): Image
abstract override fun toString(): String public abstract override fun toString(): String
} }
\ No newline at end of file
...@@ -12,8 +12,8 @@ package net.mamoe.mirai.data ...@@ -12,8 +12,8 @@ package net.mamoe.mirai.data
import net.mamoe.mirai.LowLevelAPI import net.mamoe.mirai.LowLevelAPI
@LowLevelAPI @LowLevelAPI
interface FriendInfo { public interface FriendInfo {
val uin: Long public val uin: Long
val nick: String public val nick: String
} }
\ No newline at end of file
...@@ -11,7 +11,7 @@ import net.mamoe.mirai.utils.MiraiExperimentalAPI ...@@ -11,7 +11,7 @@ import net.mamoe.mirai.utils.MiraiExperimentalAPI
*/ */
@MiraiExperimentalAPI @MiraiExperimentalAPI
@Serializable @Serializable
data class GroupActiveData( public data class GroupActiveData(
@SerialName("ec") @SerialName("ec")
val ec: Int? = null, val ec: Int? = null,
...@@ -29,7 +29,7 @@ data class GroupActiveData( ...@@ -29,7 +29,7 @@ data class GroupActiveData(
val role: Int? = 0 val role: Int? = 0
) { ) {
@Serializable @Serializable
data class GInfo( public data class GInfo(
@SerialName("g_act_num") @SerialName("g_act_num")
...@@ -66,7 +66,7 @@ data class GroupActiveData( ...@@ -66,7 +66,7 @@ data class GroupActiveData(
val isEnd: Int? = null val isEnd: Int? = null
) { ) {
@Serializable @Serializable
data class GActNum( public data class GActNum(
@SerialName("date") @SerialName("date")
val date: String? = null, val date: String? = null,
...@@ -76,7 +76,7 @@ data class GroupActiveData( ...@@ -76,7 +76,7 @@ data class GroupActiveData(
) )
@Serializable @Serializable
data class GExitNum( public data class GExitNum(
@SerialName("date") @SerialName("date")
val date: String? = null, val date: String? = null,
...@@ -86,7 +86,7 @@ data class GroupActiveData( ...@@ -86,7 +86,7 @@ data class GroupActiveData(
) )
@Serializable @Serializable
data class GJoinNum( public data class GJoinNum(
@SerialName("date") @SerialName("date")
val date: String? = null, val date: String? = null,
...@@ -96,7 +96,7 @@ data class GroupActiveData( ...@@ -96,7 +96,7 @@ data class GroupActiveData(
) )
@Serializable @Serializable
data class GMemNum( public data class GMemNum(
@SerialName("date") @SerialName("date")
val date: String? = null, val date: String? = null,
...@@ -106,7 +106,7 @@ data class GroupActiveData( ...@@ -106,7 +106,7 @@ data class GroupActiveData(
) )
@Serializable @Serializable
data class GMostAct( public data class GMostAct(
@SerialName("name") @SerialName("name")
val name: String? = null, // 名称 不完整 val name: String? = null, // 名称 不完整
...@@ -122,7 +122,7 @@ data class GroupActiveData( ...@@ -122,7 +122,7 @@ data class GroupActiveData(
) )
@Serializable @Serializable
data class GSentence( public data class GSentence(
@SerialName("date") @SerialName("date")
val date: String? = null, val date: String? = null,
......
...@@ -13,7 +13,7 @@ import net.mamoe.mirai.utils.MiraiExperimentalAPI ...@@ -13,7 +13,7 @@ import net.mamoe.mirai.utils.MiraiExperimentalAPI
*/ */
@MiraiExperimentalAPI @MiraiExperimentalAPI
@Serializable @Serializable
data class GroupAnnouncementList( public data class GroupAnnouncementList(
val ec: Int, //状态码 0 是正常的 val ec: Int, //状态码 0 是正常的
@SerialName("em") val msg: String, //信息 @SerialName("em") val msg: String, //信息
val feeds: List<GroupAnnouncement>? = null, //群公告列表 val feeds: List<GroupAnnouncement>? = null, //群公告列表
...@@ -22,7 +22,7 @@ data class GroupAnnouncementList( ...@@ -22,7 +22,7 @@ data class GroupAnnouncementList(
@MiraiExperimentalAPI @MiraiExperimentalAPI
@Serializable @Serializable
data class GroupAnnouncement( public data class GroupAnnouncement(
@SerialName("u") val sender: Long = 0, @SerialName("u") val sender: Long = 0,
val msg: GroupAnnouncementMsg, val msg: GroupAnnouncementMsg,
val settings: GroupAnnouncementSettings? = null, val settings: GroupAnnouncementSettings? = null,
...@@ -30,12 +30,12 @@ data class GroupAnnouncement( ...@@ -30,12 +30,12 @@ data class GroupAnnouncement(
@SerialName("read_num") val readNum: Int = 0, @SerialName("read_num") val readNum: Int = 0,
@SerialName("is_read") val isRead: Int = 0, @SerialName("is_read") val isRead: Int = 0,
val pinned: Int = 0, val pinned: Int = 0,
val fid:String? = null //公告的id val fid: String? = null //公告的id
) )
@MiraiExperimentalAPI @MiraiExperimentalAPI
@Serializable @Serializable
data class GroupAnnouncementMsg( public data class GroupAnnouncementMsg(
val text: String, val text: String,
val text_face: String? = null, val text_face: String? = null,
val title: String? = null val title: String? = null
...@@ -43,7 +43,7 @@ data class GroupAnnouncementMsg( ...@@ -43,7 +43,7 @@ data class GroupAnnouncementMsg(
@MiraiExperimentalAPI @MiraiExperimentalAPI
@Serializable @Serializable
data class GroupAnnouncementSettings( public data class GroupAnnouncementSettings(
@SerialName("is_show_edit_card") val isShowEditCard: Int = 0, @SerialName("is_show_edit_card") val isShowEditCard: Int = 0,
@SerialName("remind_ts") val remindTs: Int = 0, @SerialName("remind_ts") val remindTs: Int = 0,
@SerialName("tip_window_type") val tipWindowType: Int = 0, @SerialName("tip_window_type") val tipWindowType: Int = 0,
......
...@@ -9,61 +9,61 @@ import net.mamoe.mirai.LowLevelAPI ...@@ -9,61 +9,61 @@ import net.mamoe.mirai.LowLevelAPI
* 通过 [Bot._lowLevelQueryGroupInfo] 得到 * 通过 [Bot._lowLevelQueryGroupInfo] 得到
*/ */
@LowLevelAPI @LowLevelAPI
interface GroupInfo { public interface GroupInfo {
/** /**
* Uin * Uin
*/ */
val uin: Long public val uin: Long
/** /**
* 群号码 * 群号码
*/ // 由 uin 计算得到 */ // 由 uin 计算得到
val groupCode: Long public val groupCode: Long
/** /**
* 名称 * 名称
*/ */
val name: String // 不一定能获取到 public val name: String // 不一定能获取到
/** /**
* 群主 * 群主
*/ */
val owner: Long // 不一定能获取到 public val owner: Long // 不一定能获取到
/** /**
* 入群公告 * 入群公告
*/ */
val memo: String // 不一定能获取到 public val memo: String // 不一定能获取到
/** /**
* 允许群员邀请其他人加入群 * 允许群员邀请其他人加入群
*/ */
val allowMemberInvite: Boolean public val allowMemberInvite: Boolean
/** /**
* 允许匿名聊天 * 允许匿名聊天
*/ */
val allowAnonymousChat: Boolean public val allowAnonymousChat: Boolean
/** /**
* 自动审批加群请求 * 自动审批加群请求
*/ */
val autoApprove: Boolean public val autoApprove: Boolean
/** /**
* 坦白说开启状态 * 坦白说开启状态
*/ */
val confessTalk: Boolean public val confessTalk: Boolean
/** /**
* 全员禁言 * 全员禁言
*/ */
val muteAll: Boolean public val muteAll: Boolean
/** /**
* 机器人被禁言还剩时间, 秒. * 机器人被禁言还剩时间, 秒.
*/ */
val botMuteTimestamp: Int public val botMuteTimestamp: Int
/* /*
/** /**
......
...@@ -13,12 +13,12 @@ import net.mamoe.mirai.LowLevelAPI ...@@ -13,12 +13,12 @@ import net.mamoe.mirai.LowLevelAPI
import net.mamoe.mirai.contact.MemberPermission import net.mamoe.mirai.contact.MemberPermission
@LowLevelAPI @LowLevelAPI
interface MemberInfo : FriendInfo { public interface MemberInfo : FriendInfo {
val nameCard: String public val nameCard: String
val permission: MemberPermission public val permission: MemberPermission
val specialTitle: String public val specialTitle: String
val muteTimestamp: Int public val muteTimestamp: Int
} }
\ No newline at end of file
...@@ -14,11 +14,12 @@ package net.mamoe.mirai.data ...@@ -14,11 +14,12 @@ package net.mamoe.mirai.data
/** /**
* 在线状态 * 在线状态
*/ */
enum class OnlineStatus(val id: Int) { public enum class OnlineStatus(public val id: Int) {
/** /**
* 我在线上 * 我在线上
*/ */
ONLINE(11), ONLINE(11),
/** /**
* 离线 * 离线
*/ */
...@@ -38,14 +39,17 @@ enum class OnlineStatus(val id: Int) { ...@@ -38,14 +39,17 @@ enum class OnlineStatus(val id: Int) {
* 忙碌 * 忙碌
*/ */
BUSY(50), BUSY(50),
/** /**
* Q 我吧 * Q 我吧
*/ */
Q_ME(60), Q_ME(60),
/** /**
* 请勿打扰 * 请勿打扰
*/ */
DND(70), DND(70),
/** /**
* 离线但接收消息 * 离线但接收消息
*/ */
...@@ -56,8 +60,8 @@ enum class OnlineStatus(val id: Int) { ...@@ -56,8 +60,8 @@ enum class OnlineStatus(val id: Int) {
*/ */
UNKNOWN(-1); UNKNOWN(-1);
companion object { public companion object {
fun ofId(id: Int): OnlineStatus = values().first { it.id == id } public fun ofId(id: Int): OnlineStatus = values().first { it.id == id }
fun ofIdOrNull(id: Int): OnlineStatus? = values().firstOrNull { it.id == id } public fun ofIdOrNull(id: Int): OnlineStatus? = values().firstOrNull { it.id == id }
} }
} }
\ No newline at end of file
...@@ -44,7 +44,7 @@ import kotlin.jvm.Volatile ...@@ -44,7 +44,7 @@ import kotlin.jvm.Volatile
* *
* @see CancellableEvent 可被取消的事件 * @see CancellableEvent 可被取消的事件
*/ */
interface Event { public interface Event {
/** /**
* 事件是否已被拦截. * 事件是否已被拦截.
* *
...@@ -52,7 +52,7 @@ interface Event { ...@@ -52,7 +52,7 @@ interface Event {
* *
* @see intercept 拦截事件 * @see intercept 拦截事件
*/ */
val isIntercepted: Boolean public val isIntercepted: Boolean
/** /**
* 拦截这个事件 * 拦截这个事件
...@@ -64,7 +64,7 @@ interface Event { ...@@ -64,7 +64,7 @@ interface Event {
* @see Listener.EventPriority 查看优先级相关信息 * @see Listener.EventPriority 查看优先级相关信息
*/ */
@SinceMirai("1.0.0") @SinceMirai("1.0.0")
fun intercept() public fun intercept()
} }
/** /**
...@@ -72,11 +72,12 @@ interface Event { ...@@ -72,11 +72,12 @@ interface Event {
* *
* 在使用事件时应使用类型 [Event]. 在实现自定义事件时应继承 [AbstractEvent]. * 在使用事件时应使用类型 [Event]. 在实现自定义事件时应继承 [AbstractEvent].
*/ */
abstract class AbstractEvent : Event { public abstract class AbstractEvent : Event {
/** 限制一个事件实例不能并行广播. (适用于 object 广播的情况) */ /** 限制一个事件实例不能并行广播. (适用于 object 广播的情况) */
@JvmField @JvmField
internal val broadCastLock = Mutex() internal val broadCastLock = Mutex()
@Suppress("PropertyName")
@JvmField @JvmField
@Volatile @Volatile
internal var _intercepted = false internal var _intercepted = false
...@@ -89,13 +90,13 @@ abstract class AbstractEvent : Event { ...@@ -89,13 +90,13 @@ abstract class AbstractEvent : Event {
* @see Event.isIntercepted * @see Event.isIntercepted
*/ */
@SinceMirai("1.0.0") @SinceMirai("1.0.0")
override val isIntercepted: Boolean public override val isIntercepted: Boolean
get() = _intercepted get() = _intercepted
/** /**
* @see Event.intercept * @see Event.intercept
*/ */
override fun intercept() { public override fun intercept() {
_intercepted = true _intercepted = true
} }
...@@ -103,12 +104,12 @@ abstract class AbstractEvent : Event { ...@@ -103,12 +104,12 @@ abstract class AbstractEvent : Event {
/** /**
* @see CancellableEvent.isCancelled * @see CancellableEvent.isCancelled
*/ */
val isCancelled: Boolean get() = _cancelled public val isCancelled: Boolean get() = _cancelled
/** /**
* @see CancellableEvent.cancel * @see CancellableEvent.cancel
*/ */
fun cancel() { public fun cancel() {
check(this is CancellableEvent) { check(this is CancellableEvent) {
"Event $this is not cancellable" "Event $this is not cancellable"
} }
...@@ -119,14 +120,14 @@ abstract class AbstractEvent : Event { ...@@ -119,14 +120,14 @@ abstract class AbstractEvent : Event {
/** /**
* 可被取消的事件 * 可被取消的事件
*/ */
interface CancellableEvent : Event { public interface CancellableEvent : Event {
/** /**
* 事件是否已被取消. * 事件是否已被取消.
* *
* 事件需实现 [CancellableEvent] 接口才可以被取消, * 事件需实现 [CancellableEvent] 接口才可以被取消,
* 否则此属性固定返回 false. * 否则此属性固定返回 false.
*/ */
val isCancelled: Boolean public val isCancelled: Boolean
/** /**
* 取消这个事件. * 取消这个事件.
...@@ -134,7 +135,7 @@ interface CancellableEvent : Event { ...@@ -134,7 +135,7 @@ interface CancellableEvent : Event {
* *
* @throws IllegalStateException 当事件未实现接口 [CancellableEvent] 时抛出 * @throws IllegalStateException 当事件未实现接口 [CancellableEvent] 时抛出
*/ */
fun cancel() public fun cancel()
} }
/** /**
...@@ -146,7 +147,7 @@ interface CancellableEvent : Event { ...@@ -146,7 +147,7 @@ interface CancellableEvent : Event {
* @see __broadcastJava Java 使用 * @see __broadcastJava Java 使用
*/ */
@JvmSynthetic @JvmSynthetic
suspend fun <E : Event> E.broadcast(): E = apply { public suspend fun <E : Event> E.broadcast(): E = apply {
check(this is AbstractEvent) { check(this is AbstractEvent) {
"Events must extend AbstractEvent" "Events must extend AbstractEvent"
} }
...@@ -168,7 +169,7 @@ suspend fun <E : Event> E.broadcast(): E = apply { ...@@ -168,7 +169,7 @@ suspend fun <E : Event> E.broadcast(): E = apply {
@Suppress("FunctionName") @Suppress("FunctionName")
@JvmName("broadcast") @JvmName("broadcast")
@JavaFriendlyAPI @JavaFriendlyAPI
fun <E : Event> E.__broadcastJava(): E = apply { public fun <E : Event> E.__broadcastJava(): E = apply {
if (this is BroadcastControllable && !this.shouldBroadcast) { if (this is BroadcastControllable && !this.shouldBroadcast) {
return@apply return@apply
} }
...@@ -180,16 +181,16 @@ fun <E : Event> E.__broadcastJava(): E = apply { ...@@ -180,16 +181,16 @@ fun <E : Event> E.__broadcastJava(): E = apply {
* 所有的 `subscribe` 都能正常添加到监听器列表, 但所有的广播都会直接返回. * 所有的 `subscribe` 都能正常添加到监听器列表, 但所有的广播都会直接返回.
*/ */
@MiraiExperimentalAPI @MiraiExperimentalAPI
var EventDisabled = false public var EventDisabled: Boolean = false
/** /**
* 可控制是否需要广播这个事件 * 可控制是否需要广播这个事件
*/ */
interface BroadcastControllable : Event { public interface BroadcastControllable : Event {
/** /**
* 返回 `false` 时将不会广播这个事件. * 返回 `false` 时将不会广播这个事件.
*/ */
val shouldBroadcast: Boolean public val shouldBroadcast: Boolean
get() = true get() = true
} }
...@@ -55,7 +55,7 @@ import kotlin.jvm.JvmName ...@@ -55,7 +55,7 @@ import kotlin.jvm.JvmName
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
@kotlin.internal.LowPriorityInOverloadResolution @kotlin.internal.LowPriorityInOverloadResolution
fun <R> Bot.subscribeMessages( public fun <R> Bot.subscribeMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
priority: Listener.EventPriority = EventPriority.MONITOR, priority: Listener.EventPriority = EventPriority.MONITOR,
...@@ -80,7 +80,7 @@ fun <R> Bot.subscribeMessages( ...@@ -80,7 +80,7 @@ fun <R> Bot.subscribeMessages(
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
fun <R> Bot.subscribeGroupMessages( public fun <R> Bot.subscribeGroupMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
priority: Listener.EventPriority = EventPriority.MONITOR, priority: Listener.EventPriority = EventPriority.MONITOR,
...@@ -105,7 +105,7 @@ fun <R> Bot.subscribeGroupMessages( ...@@ -105,7 +105,7 @@ fun <R> Bot.subscribeGroupMessages(
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
fun <R> Bot.subscribeFriendMessages( public fun <R> Bot.subscribeFriendMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
priority: Listener.EventPriority = EventPriority.MONITOR, priority: Listener.EventPriority = EventPriority.MONITOR,
...@@ -131,7 +131,7 @@ fun <R> Bot.subscribeFriendMessages( ...@@ -131,7 +131,7 @@ fun <R> Bot.subscribeFriendMessages(
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
fun <R> Bot.subscribeTempMessages( public fun <R> Bot.subscribeTempMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
priority: Listener.EventPriority = EventPriority.MONITOR, priority: Listener.EventPriority = EventPriority.MONITOR,
...@@ -156,7 +156,7 @@ fun <R> Bot.subscribeTempMessages( ...@@ -156,7 +156,7 @@ fun <R> Bot.subscribeTempMessages(
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
inline fun <reified E : BotEvent> Bot.incoming( public inline fun <reified E : BotEvent> Bot.incoming(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
priority: Listener.EventPriority = EventPriority.MONITOR, priority: Listener.EventPriority = EventPriority.MONITOR,
...@@ -175,7 +175,7 @@ inline fun <reified E : BotEvent> Bot.incoming( ...@@ -175,7 +175,7 @@ inline fun <reified E : BotEvent> Bot.incoming(
@kotlin.internal.LowPriorityInOverloadResolution @kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@PlannedRemoval("1.2.0") @PlannedRemoval("1.2.0")
fun <R> CoroutineScope.subscribeMessages( public fun <R> CoroutineScope.subscribeMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
listeners: MessagePacketSubscribersBuilder.() -> R listeners: MessagePacketSubscribersBuilder.() -> R
...@@ -184,7 +184,7 @@ fun <R> CoroutineScope.subscribeMessages( ...@@ -184,7 +184,7 @@ fun <R> CoroutineScope.subscribeMessages(
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@kotlin.internal.LowPriorityInOverloadResolution @kotlin.internal.LowPriorityInOverloadResolution
@PlannedRemoval("1.2.0") @PlannedRemoval("1.2.0")
fun <R> CoroutineScope.subscribeGroupMessages( public fun <R> CoroutineScope.subscribeGroupMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
listeners: GroupMessageSubscribersBuilder.() -> R listeners: GroupMessageSubscribersBuilder.() -> R
...@@ -193,7 +193,7 @@ fun <R> CoroutineScope.subscribeGroupMessages( ...@@ -193,7 +193,7 @@ fun <R> CoroutineScope.subscribeGroupMessages(
@kotlin.internal.LowPriorityInOverloadResolution @kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@PlannedRemoval("1.2.0") @PlannedRemoval("1.2.0")
fun <R> CoroutineScope.subscribeFriendMessages( public fun <R> CoroutineScope.subscribeFriendMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
listeners: FriendMessageSubscribersBuilder.() -> R listeners: FriendMessageSubscribersBuilder.() -> R
...@@ -202,7 +202,7 @@ fun <R> CoroutineScope.subscribeFriendMessages( ...@@ -202,7 +202,7 @@ fun <R> CoroutineScope.subscribeFriendMessages(
@kotlin.internal.LowPriorityInOverloadResolution @kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@PlannedRemoval("1.2.0") @PlannedRemoval("1.2.0")
fun <R> CoroutineScope.subscribeTempMessages( public fun <R> CoroutineScope.subscribeTempMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
listeners: TempMessageSubscribersBuilder.() -> R listeners: TempMessageSubscribersBuilder.() -> R
...@@ -211,7 +211,7 @@ fun <R> CoroutineScope.subscribeTempMessages( ...@@ -211,7 +211,7 @@ fun <R> CoroutineScope.subscribeTempMessages(
@kotlin.internal.LowPriorityInOverloadResolution @kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@PlannedRemoval("1.2.0") @PlannedRemoval("1.2.0")
fun <R> Bot.subscribeMessages( public fun <R> Bot.subscribeMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
listeners: MessagePacketSubscribersBuilder.() -> R listeners: MessagePacketSubscribersBuilder.() -> R
...@@ -220,7 +220,7 @@ fun <R> Bot.subscribeMessages( ...@@ -220,7 +220,7 @@ fun <R> Bot.subscribeMessages(
@kotlin.internal.LowPriorityInOverloadResolution @kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@PlannedRemoval("1.2.0") @PlannedRemoval("1.2.0")
fun <R> Bot.subscribeGroupMessages( public fun <R> Bot.subscribeGroupMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
listeners: GroupMessageSubscribersBuilder.() -> R listeners: GroupMessageSubscribersBuilder.() -> R
...@@ -229,7 +229,7 @@ fun <R> Bot.subscribeGroupMessages( ...@@ -229,7 +229,7 @@ fun <R> Bot.subscribeGroupMessages(
@kotlin.internal.LowPriorityInOverloadResolution @kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@PlannedRemoval("1.2.0") @PlannedRemoval("1.2.0")
fun <R> Bot.subscribeFriendMessages( public fun <R> Bot.subscribeFriendMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
listeners: FriendMessageSubscribersBuilder.() -> R listeners: FriendMessageSubscribersBuilder.() -> R
...@@ -238,7 +238,7 @@ fun <R> Bot.subscribeFriendMessages( ...@@ -238,7 +238,7 @@ fun <R> Bot.subscribeFriendMessages(
@kotlin.internal.LowPriorityInOverloadResolution @kotlin.internal.LowPriorityInOverloadResolution
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@PlannedRemoval("1.2.0") @PlannedRemoval("1.2.0")
fun <R> Bot.subscribeTempMessages( public fun <R> Bot.subscribeTempMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
listeners: TempMessageSubscribersBuilder.() -> R listeners: TempMessageSubscribersBuilder.() -> R
......
package net.mamoe.mirai.event.events package net.mamoe.mirai.event.events
@Suppress("unused") @Suppress("unused")
class EventCancelledException : RuntimeException { public class EventCancelledException : RuntimeException {
constructor() : super() public constructor() : super()
constructor(message: String?) : super(message) public constructor(message: String?) : super(message)
constructor(message: String?, cause: Throwable?) : super(message, cause) public constructor(message: String?, cause: Throwable?) : super(message, cause)
constructor(cause: Throwable?) : super(cause) public constructor(cause: Throwable?) : super(cause)
} }
...@@ -28,23 +28,32 @@ import kotlin.jvm.JvmName ...@@ -28,23 +28,32 @@ import kotlin.jvm.JvmName
/** /**
* [Bot] 登录完成, 好友列表, 群组列表初始化完成 * [Bot] 登录完成, 好友列表, 群组列表初始化完成
*/ */
data class BotOnlineEvent internal constructor(override val bot: Bot) : BotActiveEvent, AbstractEvent() public data class BotOnlineEvent internal constructor(
public override val bot: Bot
) : BotActiveEvent, AbstractEvent()
/** /**
* [Bot] 离线. * [Bot] 离线.
*/ */
sealed class BotOfflineEvent : BotEvent, AbstractEvent() { public sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
/** /**
* 主动离线. 主动广播这个事件也可以让 [Bot] 关闭. * 主动离线. 主动广播这个事件也可以让 [Bot] 关闭.
*/ */
data class Active(override val bot: Bot, override val cause: Throwable?) : BotOfflineEvent(), BotActiveEvent, public data class Active(
public override val bot: Bot,
public override val cause: Throwable?
) : BotOfflineEvent(), BotActiveEvent,
CauseAware CauseAware
/** /**
* 被挤下线 * 被挤下线
*/ */
data class Force internal constructor(override val bot: Bot, val title: String, val message: String) : public data class Force internal constructor(
public override val bot: Bot,
public val title: String,
public val message: String
) :
BotOfflineEvent(), Packet, BotOfflineEvent(), Packet,
BotPassiveEvent BotPassiveEvent
...@@ -53,14 +62,20 @@ sealed class BotOfflineEvent : BotEvent, AbstractEvent() { ...@@ -53,14 +62,20 @@ sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
*/ */
@SinceMirai("1.1.0") @SinceMirai("1.1.0")
@MiraiInternalAPI("This is very experimental and might be changed") @MiraiInternalAPI("This is very experimental and might be changed")
data class MsfOffline internal constructor(override val bot: Bot, override val cause: Throwable?) : public data class MsfOffline internal constructor(
public override val bot: Bot,
public override val cause: Throwable?
) :
BotOfflineEvent(), Packet, BotOfflineEvent(), Packet,
BotPassiveEvent, CauseAware BotPassiveEvent, CauseAware
/** /**
* 因网络问题而掉线 * 因网络问题而掉线
*/ */
data class Dropped internal constructor(override val bot: Bot, override val cause: Throwable?) : BotOfflineEvent(), public data class Dropped internal constructor(
public override val bot: Bot,
public override val cause: Throwable?
) : BotOfflineEvent(),
Packet, Packet,
BotPassiveEvent, CauseAware BotPassiveEvent, CauseAware
...@@ -68,28 +83,31 @@ sealed class BotOfflineEvent : BotEvent, AbstractEvent() { ...@@ -68,28 +83,31 @@ sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
* 服务器主动要求更换另一个服务器 * 服务器主动要求更换另一个服务器
*/ */
@MiraiInternalAPI @MiraiInternalAPI
data class RequireReconnect internal constructor(override val bot: Bot) : BotOfflineEvent(), Packet, BotPassiveEvent public data class RequireReconnect internal constructor(
public override val bot: Bot
) : BotOfflineEvent(), Packet,
BotPassiveEvent
@MiraiExperimentalAPI @MiraiExperimentalAPI
interface CauseAware { public interface CauseAware {
val cause: Throwable? public val cause: Throwable?
} }
} }
/** /**
* [Bot] 主动或被动重新登录. 在此事件广播前就已经登录完毕. * [Bot] 主动或被动重新登录. 在此事件广播前就已经登录完毕.
*/ */
data class BotReloginEvent internal constructor( public data class BotReloginEvent internal constructor(
override val bot: Bot, public override val bot: Bot,
val cause: Throwable? public val cause: Throwable?
) : BotEvent, BotActiveEvent, AbstractEvent() ) : BotEvent, BotActiveEvent, AbstractEvent()
/** /**
* [Bot] 头像被修改(通过其他客户端修改了头像). 在此事件广播前就已经修改完毕. * [Bot] 头像被修改(通过其他客户端修改了头像). 在此事件广播前就已经修改完毕.
* @see FriendAvatarChangedEvent * @see FriendAvatarChangedEvent
*/ */
data class BotAvatarChangedEvent( public data class BotAvatarChangedEvent(
override val bot: Bot public override val bot: Bot
) : BotEvent, Packet, AbstractEvent() ) : BotEvent, Packet, AbstractEvent()
// region 图片 // region 图片
......
...@@ -28,54 +28,54 @@ import kotlin.jvm.* ...@@ -28,54 +28,54 @@ import kotlin.jvm.*
/** /**
* 好友昵称改变事件. 目前仅支持解析 (来自 PC 端的修改). * 好友昵称改变事件. 目前仅支持解析 (来自 PC 端的修改).
*/ */
data class FriendRemarkChangeEvent internal constructor( public data class FriendRemarkChangeEvent internal constructor(
override val friend: Friend, public override val friend: Friend,
val newName: String public val newName: String
) : FriendEvent, Packet, AbstractEvent() ) : FriendEvent, Packet, AbstractEvent()
/** /**
* 成功添加了一个新好友的事件 * 成功添加了一个新好友的事件
*/ */
data class FriendAddEvent internal constructor( public data class FriendAddEvent internal constructor(
/** /**
* 新好友. 已经添加到 [Bot.friends] * 新好友. 已经添加到 [Bot.friends]
*/ */
override val friend: Friend public override val friend: Friend
) : FriendEvent, Packet, AbstractEvent() ) : FriendEvent, Packet, AbstractEvent()
/** /**
* 好友已被删除的事件. * 好友已被删除的事件.
*/ */
data class FriendDeleteEvent internal constructor( public data class FriendDeleteEvent internal constructor(
override val friend: Friend public override val friend: Friend
) : FriendEvent, Packet, AbstractEvent() ) : FriendEvent, Packet, AbstractEvent()
/** /**
* 一个账号请求添加机器人为好友的事件 * 一个账号请求添加机器人为好友的事件
*/ */
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
data class NewFriendRequestEvent internal constructor( public data class NewFriendRequestEvent internal constructor(
override val bot: Bot, public override val bot: Bot,
/** /**
* 事件唯一识别号 * 事件唯一识别号
*/ */
val eventId: Long, public val eventId: Long,
/** /**
* 申请好友消息 * 申请好友消息
*/ */
val message: String, public val message: String,
/** /**
* 请求人 [User.id] * 请求人 [User.id]
*/ */
val fromId: Long, public val fromId: Long,
/** /**
* 来自群 [Group.id], 其他途径时为 0 * 来自群 [Group.id], 其他途径时为 0
*/ */
val fromGroupId: Long, public val fromGroupId: Long,
/** /**
* 群名片或好友昵称 * 群名片或好友昵称
*/ */
val fromNick: String public val fromNick: String
) : BotEvent, Packet, AbstractEvent() { ) : BotEvent, Packet, AbstractEvent() {
@JvmField @JvmField
internal val responded: MiraiAtomicBoolean = MiraiAtomicBoolean(false) internal val responded: MiraiAtomicBoolean = MiraiAtomicBoolean(false)
...@@ -83,23 +83,23 @@ data class NewFriendRequestEvent internal constructor( ...@@ -83,23 +83,23 @@ data class NewFriendRequestEvent internal constructor(
/** /**
* @return 申请人来自的群. 当申请人来自其他途径申请时为 `null` * @return 申请人来自的群. 当申请人来自其他途径申请时为 `null`
*/ */
val fromGroup: Group? = if (fromGroupId == 0L) null else bot.getGroup(fromGroupId) public val fromGroup: Group? = if (fromGroupId == 0L) null else bot.getGroup(fromGroupId)
@JvmSynthetic @JvmSynthetic
suspend fun accept() = bot.acceptNewFriendRequest(this) public suspend fun accept(): Unit = bot.acceptNewFriendRequest(this)
@JvmSynthetic @JvmSynthetic
suspend fun reject(blackList: Boolean = false) = bot.rejectNewFriendRequest(this, blackList) public suspend fun reject(blackList: Boolean = false): Unit = bot.rejectNewFriendRequest(this, blackList)
@JavaFriendlyAPI @JavaFriendlyAPI
@JvmName("accept") @JvmName("accept")
fun __acceptBlockingForJava__() = runBlocking { accept() } public fun __acceptBlockingForJava__(): Unit = runBlocking { accept() }
@JavaFriendlyAPI @JavaFriendlyAPI
@JvmOverloads @JvmOverloads
@JvmName("reject") @JvmName("reject")
fun __rejectBlockingForJava__(blackList: Boolean = false) = public fun __rejectBlockingForJava__(blackList: Boolean = false): Unit =
runBlocking { reject(blackList) } runBlocking { reject(blackList) }
} }
...@@ -107,7 +107,7 @@ data class NewFriendRequestEvent internal constructor( ...@@ -107,7 +107,7 @@ data class NewFriendRequestEvent internal constructor(
/** /**
* [Friend] 头像被修改. 在此事件广播前就已经修改完毕. * [Friend] 头像被修改. 在此事件广播前就已经修改完毕.
*/ */
data class FriendAvatarChangedEvent internal constructor( public data class FriendAvatarChangedEvent internal constructor(
override val friend: Friend public override val friend: Friend
) : FriendEvent, Packet, AbstractEvent() ) : FriendEvent, Packet, AbstractEvent()
...@@ -22,26 +22,26 @@ import kotlin.jvm.JvmSynthetic ...@@ -22,26 +22,26 @@ import kotlin.jvm.JvmSynthetic
/** /**
* 有关一个 [Bot] 的事件 * 有关一个 [Bot] 的事件
*/ */
interface BotEvent : Event { public interface BotEvent : Event {
val bot: Bot public val bot: Bot
} }
/** /**
* [Bot] 被动接收的事件. 这些事件可能与机器人有关 * [Bot] 被动接收的事件. 这些事件可能与机器人有关
*/ */
interface BotPassiveEvent : BotEvent public interface BotPassiveEvent : BotEvent
/** /**
* 由 [Bot] 主动发起的动作的事件 * 由 [Bot] 主动发起的动作的事件
*/ */
interface BotActiveEvent : BotEvent public interface BotActiveEvent : BotEvent
/** /**
* 有关群的事件 * 有关群的事件
*/ */
interface GroupEvent : BotEvent { public interface GroupEvent : BotEvent {
val group: Group public val group: Group
override val bot: Bot override val bot: Bot
get() = group.bot get() = group.bot
} }
...@@ -49,8 +49,8 @@ interface GroupEvent : BotEvent { ...@@ -49,8 +49,8 @@ interface GroupEvent : BotEvent {
/** /**
* 有关群成员的事件 * 有关群成员的事件
*/ */
interface GroupMemberEvent : GroupEvent { public interface GroupMemberEvent : GroupEvent {
val member: Member public val member: Member
override val group: Group override val group: Group
get() = member.group get() = member.group
} }
...@@ -60,11 +60,11 @@ interface GroupMemberEvent : GroupEvent { ...@@ -60,11 +60,11 @@ interface GroupMemberEvent : GroupEvent {
* @see isByBot * @see isByBot
* @see operatorOrBot * @see operatorOrBot
*/ */
interface GroupOperableEvent : GroupEvent { public interface GroupOperableEvent : GroupEvent {
/** /**
* 操作人, 为 `null` 时为 [Bot] 操作 * 操作人, 为 `null` 时为 [Bot] 操作
*/ */
val operator: Member? public val operator: Member?
} }
/** /**
...@@ -72,7 +72,7 @@ interface GroupOperableEvent : GroupEvent { ...@@ -72,7 +72,7 @@ interface GroupOperableEvent : GroupEvent {
*/ */
@HidesMembers @HidesMembers
@get:JvmSynthetic // inline: planning to change to another file (1.2.0) @get:JvmSynthetic // inline: planning to change to another file (1.2.0)
inline val GroupOperableEvent.isByBot: Boolean public inline val GroupOperableEvent.isByBot: Boolean
get() = operator == null get() = operator == null
/** /**
...@@ -80,14 +80,14 @@ inline val GroupOperableEvent.isByBot: Boolean ...@@ -80,14 +80,14 @@ inline val GroupOperableEvent.isByBot: Boolean
* 当操作人为 [Bot] 时获取 [Group.botAsMember] * 当操作人为 [Bot] 时获取 [Group.botAsMember]
*/ */
@get:JvmSynthetic // inline: planning to change to another file (1.2.0) @get:JvmSynthetic // inline: planning to change to another file (1.2.0)
inline val GroupOperableEvent.operatorOrBot: Member public inline val GroupOperableEvent.operatorOrBot: Member
get() = this.operator ?: this.group.botAsMember get() = this.operator ?: this.group.botAsMember
/** /**
* 有关好友的事件 * 有关好友的事件
*/ */
interface FriendEvent : BotEvent { public interface FriendEvent : BotEvent {
val friend: Friend public val friend: Friend
final override val bot: Bot get() = friend.bot final override val bot: Bot get() = friend.bot
} }
\ No newline at end of file
...@@ -33,7 +33,7 @@ import kotlin.reflect.KClass ...@@ -33,7 +33,7 @@ import kotlin.reflect.KClass
* @throws Throwable 当 [mapper] 抛出任何异常时, 本函数会抛出该异常 * @throws Throwable 当 [mapper] 抛出任何异常时, 本函数会抛出该异常
*/ */
@JvmSynthetic @JvmSynthetic
suspend inline fun <reified E : Event, R : Any> syncFromEvent( public suspend inline fun <reified E : Event, R : Any> syncFromEvent(
timeoutMillis: Long = -1, timeoutMillis: Long = -1,
priority: Listener.EventPriority = EventPriority.MONITOR, priority: Listener.EventPriority = EventPriority.MONITOR,
crossinline mapper: suspend E.(E) -> R? crossinline mapper: suspend E.(E) -> R?
...@@ -66,7 +66,7 @@ suspend inline fun <reified E : Event, R : Any> syncFromEvent( ...@@ -66,7 +66,7 @@ suspend inline fun <reified E : Event, R : Any> syncFromEvent(
* @throws Throwable 当 [mapper] 抛出任何异常时, 本函数会抛出该异常 * @throws Throwable 当 [mapper] 抛出任何异常时, 本函数会抛出该异常
*/ */
@JvmSynthetic @JvmSynthetic
suspend inline fun <reified E : Event, R : Any> syncFromEventOrNull( public suspend inline fun <reified E : Event, R : Any> syncFromEventOrNull(
timeoutMillis: Long, timeoutMillis: Long,
priority: Listener.EventPriority = EventPriority.MONITOR, priority: Listener.EventPriority = EventPriority.MONITOR,
crossinline mapper: suspend E.(E) -> R? crossinline mapper: suspend E.(E) -> R?
...@@ -94,7 +94,7 @@ suspend inline fun <reified E : Event, R : Any> syncFromEventOrNull( ...@@ -94,7 +94,7 @@ suspend inline fun <reified E : Event, R : Any> syncFromEventOrNull(
*/ */
@JvmSynthetic @JvmSynthetic
@Suppress("DeferredIsResult") @Suppress("DeferredIsResult")
inline fun <reified E : Event, R : Any> CoroutineScope.asyncFromEventOrNull( public inline fun <reified E : Event, R : Any> CoroutineScope.asyncFromEventOrNull(
timeoutMillis: Long, timeoutMillis: Long,
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
priority: Listener.EventPriority = EventPriority.MONITOR, priority: Listener.EventPriority = EventPriority.MONITOR,
...@@ -123,7 +123,7 @@ inline fun <reified E : Event, R : Any> CoroutineScope.asyncFromEventOrNull( ...@@ -123,7 +123,7 @@ inline fun <reified E : Event, R : Any> CoroutineScope.asyncFromEventOrNull(
*/ */
@JvmSynthetic @JvmSynthetic
@Suppress("DeferredIsResult") @Suppress("DeferredIsResult")
inline fun <reified E : Event, R : Any> CoroutineScope.asyncFromEvent( public inline fun <reified E : Event, R : Any> CoroutineScope.asyncFromEvent(
timeoutMillis: Long = -1, timeoutMillis: Long = -1,
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
priority: Listener.EventPriority = EventPriority.MONITOR, priority: Listener.EventPriority = EventPriority.MONITOR,
......
...@@ -31,7 +31,7 @@ import kotlin.reflect.KClass ...@@ -31,7 +31,7 @@ import kotlin.reflect.KClass
* @throws TimeoutCancellationException 在超时后抛出. * @throws TimeoutCancellationException 在超时后抛出.
*/ */
@JvmSynthetic @JvmSynthetic
suspend inline fun <reified E : Event> nextEvent( public suspend inline fun <reified E : Event> nextEvent(
timeoutMillis: Long = -1, timeoutMillis: Long = -1,
priority: Listener.EventPriority = EventPriority.MONITOR priority: Listener.EventPriority = EventPriority.MONITOR
): E { ): E {
...@@ -53,7 +53,7 @@ suspend inline fun <reified E : Event> nextEvent( ...@@ -53,7 +53,7 @@ suspend inline fun <reified E : Event> nextEvent(
* @return 事件实例, 在超时后返回 `null` * @return 事件实例, 在超时后返回 `null`
*/ */
@JvmSynthetic @JvmSynthetic
suspend inline fun <reified E : Event> nextEventOrNull( public suspend inline fun <reified E : Event> nextEventOrNull(
timeoutMillis: Long, timeoutMillis: Long,
priority: Listener.EventPriority = EventPriority.MONITOR priority: Listener.EventPriority = EventPriority.MONITOR
): E? { ): E? {
...@@ -77,7 +77,7 @@ suspend inline fun <reified E : Event> nextEventOrNull( ...@@ -77,7 +77,7 @@ suspend inline fun <reified E : Event> nextEventOrNull(
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
@JvmSynthetic @JvmSynthetic
suspend inline fun <reified E : BotEvent> Bot.nextEvent( public suspend inline fun <reified E : BotEvent> Bot.nextEvent(
timeoutMillis: Long = -1, timeoutMillis: Long = -1,
priority: Listener.EventPriority = EventPriority.MONITOR priority: Listener.EventPriority = EventPriority.MONITOR
): E { ): E {
......
...@@ -29,7 +29,7 @@ import kotlin.coroutines.EmptyCoroutineContext ...@@ -29,7 +29,7 @@ import kotlin.coroutines.EmptyCoroutineContext
import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmMultifileClass
import kotlin.jvm.JvmName import kotlin.jvm.JvmName
typealias MessagePacketSubscribersBuilder = MessageSubscribersBuilder<MessageEvent, Listener<MessageEvent>, Unit, Unit> public typealias MessagePacketSubscribersBuilder = MessageSubscribersBuilder<MessageEvent, Listener<MessageEvent>, Unit, Unit>
/** /**
* 订阅来自所有 [Bot] 的所有联系人的消息事件. 联系人可以是任意群或任意好友或临时会话. * 订阅来自所有 [Bot] 的所有联系人的消息事件. 联系人可以是任意群或任意好友或临时会话.
...@@ -39,7 +39,7 @@ typealias MessagePacketSubscribersBuilder = MessageSubscribersBuilder<MessageEve ...@@ -39,7 +39,7 @@ typealias MessagePacketSubscribersBuilder = MessageSubscribersBuilder<MessageEve
* @see CoroutineScope.incoming 打开一个指定事件的接收通道 * @see CoroutineScope.incoming 打开一个指定事件的接收通道
*/ */
fun <R> CoroutineScope.subscribeMessages( public fun <R> CoroutineScope.subscribeMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
priority: Listener.EventPriority = EventPriority.MONITOR, priority: Listener.EventPriority = EventPriority.MONITOR,
...@@ -63,7 +63,7 @@ fun <R> CoroutineScope.subscribeMessages( ...@@ -63,7 +63,7 @@ fun <R> CoroutineScope.subscribeMessages(
}.run(listeners) }.run(listeners)
} }
typealias GroupMessageSubscribersBuilder = MessageSubscribersBuilder<GroupMessageEvent, Listener<GroupMessageEvent>, Unit, Unit> public typealias GroupMessageSubscribersBuilder = MessageSubscribersBuilder<GroupMessageEvent, Listener<GroupMessageEvent>, Unit, Unit>
/** /**
* 订阅来自所有 [Bot] 的所有群消息事件 * 订阅来自所有 [Bot] 的所有群消息事件
...@@ -72,7 +72,7 @@ typealias GroupMessageSubscribersBuilder = MessageSubscribersBuilder<GroupMessag ...@@ -72,7 +72,7 @@ typealias GroupMessageSubscribersBuilder = MessageSubscribersBuilder<GroupMessag
* *
* @see CoroutineScope.incoming 打开一个指定事件的接收通道 * @see CoroutineScope.incoming 打开一个指定事件的接收通道
*/ */
fun <R> CoroutineScope.subscribeGroupMessages( public fun <R> CoroutineScope.subscribeGroupMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
priority: Listener.EventPriority = EventPriority.MONITOR, priority: Listener.EventPriority = EventPriority.MONITOR,
...@@ -90,7 +90,7 @@ fun <R> CoroutineScope.subscribeGroupMessages( ...@@ -90,7 +90,7 @@ fun <R> CoroutineScope.subscribeGroupMessages(
}.run(listeners) }.run(listeners)
} }
typealias FriendMessageSubscribersBuilder = MessageSubscribersBuilder<FriendMessageEvent, Listener<FriendMessageEvent>, Unit, Unit> public typealias FriendMessageSubscribersBuilder = MessageSubscribersBuilder<FriendMessageEvent, Listener<FriendMessageEvent>, Unit, Unit>
/** /**
* 订阅来自所有 [Bot] 的所有好友消息事件 * 订阅来自所有 [Bot] 的所有好友消息事件
...@@ -99,7 +99,7 @@ typealias FriendMessageSubscribersBuilder = MessageSubscribersBuilder<FriendMess ...@@ -99,7 +99,7 @@ typealias FriendMessageSubscribersBuilder = MessageSubscribersBuilder<FriendMess
* *
* @see CoroutineScope.incoming 打开一个指定事件的接收通道 * @see CoroutineScope.incoming 打开一个指定事件的接收通道
*/ */
fun <R> CoroutineScope.subscribeFriendMessages( public fun <R> CoroutineScope.subscribeFriendMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
priority: Listener.EventPriority = EventPriority.MONITOR, priority: Listener.EventPriority = EventPriority.MONITOR,
...@@ -117,7 +117,7 @@ fun <R> CoroutineScope.subscribeFriendMessages( ...@@ -117,7 +117,7 @@ fun <R> CoroutineScope.subscribeFriendMessages(
}.run(listeners) }.run(listeners)
} }
typealias TempMessageSubscribersBuilder = MessageSubscribersBuilder<TempMessageEvent, Listener<TempMessageEvent>, Unit, Unit> public typealias TempMessageSubscribersBuilder = MessageSubscribersBuilder<TempMessageEvent, Listener<TempMessageEvent>, Unit, Unit>
/** /**
* 订阅来自所有 [Bot] 的所有临时会话消息事件 * 订阅来自所有 [Bot] 的所有临时会话消息事件
...@@ -126,7 +126,7 @@ typealias TempMessageSubscribersBuilder = MessageSubscribersBuilder<TempMessageE ...@@ -126,7 +126,7 @@ typealias TempMessageSubscribersBuilder = MessageSubscribersBuilder<TempMessageE
* *
* @see CoroutineScope.incoming 打开一个指定事件的接收通道 * @see CoroutineScope.incoming 打开一个指定事件的接收通道
*/ */
fun <R> CoroutineScope.subscribeTempMessages( public fun <R> CoroutineScope.subscribeTempMessages(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
priority: Listener.EventPriority = EventPriority.MONITOR, priority: Listener.EventPriority = EventPriority.MONITOR,
...@@ -159,7 +159,7 @@ fun <R> CoroutineScope.subscribeTempMessages( ...@@ -159,7 +159,7 @@ fun <R> CoroutineScope.subscribeTempMessages(
* @see subscribeMessages * @see subscribeMessages
* @see subscribeGroupMessages * @see subscribeGroupMessages
*/ */
inline fun <reified E : Event> CoroutineScope.incoming( public inline fun <reified E : Event> CoroutineScope.incoming(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT, concurrencyKind: Listener.ConcurrencyKind = Listener.ConcurrencyKind.CONCURRENT,
priority: Listener.EventPriority = EventPriority.MONITOR, priority: Listener.EventPriority = EventPriority.MONITOR,
......
...@@ -42,7 +42,7 @@ import kotlin.reflect.KClass ...@@ -42,7 +42,7 @@ import kotlin.reflect.KClass
/** /**
* 订阅者的状态 * 订阅者的状态
*/ */
enum class ListeningStatus { public enum class ListeningStatus {
/** /**
* 表示继续监听 * 表示继续监听
*/ */
...@@ -65,9 +65,9 @@ enum class ListeningStatus { ...@@ -65,9 +65,9 @@ enum class ListeningStatus {
* *
* 取消监听: [complete] * 取消监听: [complete]
*/ */
interface Listener<in E : Event> : CompletableJob { public interface Listener<in E : Event> : CompletableJob {
enum class ConcurrencyKind { public enum class ConcurrencyKind {
/** /**
* 并发地同时处理多个事件, 但无法保证 [onEvent] 返回 [ListeningStatus.STOPPED] 后立即停止事件监听. * 并发地同时处理多个事件, 但无法保证 [onEvent] 返回 [ListeningStatus.STOPPED] 后立即停止事件监听.
*/ */
...@@ -82,7 +82,7 @@ interface Listener<in E : Event> : CompletableJob { ...@@ -82,7 +82,7 @@ interface Listener<in E : Event> : CompletableJob {
/** /**
* 并发类型 * 并发类型
*/ */
val concurrencyKind: ConcurrencyKind public val concurrencyKind: ConcurrencyKind
/** /**
* 事件优先级. * 事件优先级.
...@@ -96,7 +96,7 @@ interface Listener<in E : Event> : CompletableJob { ...@@ -96,7 +96,7 @@ interface Listener<in E : Event> : CompletableJob {
* *
* 当事件被 [拦截][Event.intercept] 后, 优先级较低 (靠右) 的监听器将不会被调用. * 当事件被 [拦截][Event.intercept] 后, 优先级较低 (靠右) 的监听器将不会被调用.
*/ */
enum class EventPriority { public enum class EventPriority {
HIGHEST, HIGH, NORMAL, LOW, LOWEST, HIGHEST, HIGH, NORMAL, LOW, LOWEST,
...@@ -108,7 +108,7 @@ interface Listener<in E : Event> : CompletableJob { ...@@ -108,7 +108,7 @@ interface Listener<in E : Event> : CompletableJob {
*/ */
MONITOR; MONITOR;
companion object { internal companion object {
@JvmStatic @JvmStatic
internal val valuesExceptMonitor: Array<EventPriority> = arrayOf(HIGHEST, HIGH, NORMAL, LOW, LOWEST) internal val valuesExceptMonitor: Array<EventPriority> = arrayOf(HIGHEST, HIGH, NORMAL, LOW, LOWEST)
} }
...@@ -118,17 +118,17 @@ interface Listener<in E : Event> : CompletableJob { ...@@ -118,17 +118,17 @@ interface Listener<in E : Event> : CompletableJob {
* 事件优先级 * 事件优先级
* @see [EventPriority] * @see [EventPriority]
*/ */
val priority: EventPriority get() = NORMAL public val priority: EventPriority get() = NORMAL
/** /**
* 这个方法将会调用 [CoroutineScope.subscribe] 时提供的参数 `noinline handler: suspend E.(E) -> ListeningStatus`. * 这个方法将会调用 [CoroutineScope.subscribe] 时提供的参数 `noinline handler: suspend E.(E) -> ListeningStatus`.
* *
* 这个函数不会抛出任何异常, 详见 [CoroutineScope.subscribe] * 这个函数不会抛出任何异常, 详见 [CoroutineScope.subscribe]
*/ */
suspend fun onEvent(event: E): ListeningStatus public suspend fun onEvent(event: E): ListeningStatus
} }
typealias EventPriority = Listener.EventPriority public typealias EventPriority = Listener.EventPriority
// region subscribe / subscribeAlways / subscribeOnce // region subscribe / subscribeAlways / subscribeOnce
...@@ -210,7 +210,7 @@ typealias EventPriority = Listener.EventPriority ...@@ -210,7 +210,7 @@ typealias EventPriority = Listener.EventPriority
* @see subscribeFriendMessages 监听好友消息 DSL * @see subscribeFriendMessages 监听好友消息 DSL
* @see subscribeTempMessages 监听临时会话消息 DSL * @see subscribeTempMessages 监听临时会话消息 DSL
*/ */
inline fun <reified E : Event> CoroutineScope.subscribe( public inline fun <reified E : Event> CoroutineScope.subscribe(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED, concurrency: Listener.ConcurrencyKind = LOCKED,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
...@@ -224,7 +224,7 @@ inline fun <reified E : Event> CoroutineScope.subscribe( ...@@ -224,7 +224,7 @@ inline fun <reified E : Event> CoroutineScope.subscribe(
* *
* @return 监听器实例. 此监听器已经注册到指定事件上, 在事件广播时将会调用 [handler] * @return 监听器实例. 此监听器已经注册到指定事件上, 在事件广播时将会调用 [handler]
*/ */
fun <E : Event> CoroutineScope.subscribe( public fun <E : Event> CoroutineScope.subscribe(
eventClass: KClass<out E>, eventClass: KClass<out E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED, concurrency: Listener.ConcurrencyKind = LOCKED,
...@@ -247,7 +247,7 @@ fun <E : Event> CoroutineScope.subscribe( ...@@ -247,7 +247,7 @@ fun <E : Event> CoroutineScope.subscribe(
* *
* @see CoroutineScope.subscribe 获取更多说明 * @see CoroutineScope.subscribe 获取更多说明
*/ */
inline fun <reified E : Event> CoroutineScope.subscribeAlways( public inline fun <reified E : Event> CoroutineScope.subscribeAlways(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = CONCURRENT, concurrency: Listener.ConcurrencyKind = CONCURRENT,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
...@@ -259,7 +259,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeAlways( ...@@ -259,7 +259,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeAlways(
* @see CoroutineScope.subscribe * @see CoroutineScope.subscribe
* @see CoroutineScope.subscribeAlways * @see CoroutineScope.subscribeAlways
*/ */
fun <E : Event> CoroutineScope.subscribeAlways( public fun <E : Event> CoroutineScope.subscribeAlways(
eventClass: KClass<out E>, eventClass: KClass<out E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = CONCURRENT, concurrency: Listener.ConcurrencyKind = CONCURRENT,
...@@ -282,7 +282,7 @@ fun <E : Event> CoroutineScope.subscribeAlways( ...@@ -282,7 +282,7 @@ fun <E : Event> CoroutineScope.subscribeAlways(
* @see CoroutineScope.subscribe 获取更多说明 * @see CoroutineScope.subscribe 获取更多说明
*/ */
@JvmSynthetic @JvmSynthetic
inline fun <reified E : Event> CoroutineScope.subscribeOnce( public inline fun <reified E : Event> CoroutineScope.subscribeOnce(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
noinline handler: suspend E.(E) -> Unit noinline handler: suspend E.(E) -> Unit
...@@ -291,7 +291,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeOnce( ...@@ -291,7 +291,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeOnce(
/** /**
* @see CoroutineScope.subscribeOnce * @see CoroutineScope.subscribeOnce
*/ */
fun <E : Event> CoroutineScope.subscribeOnce( public fun <E : Event> CoroutineScope.subscribeOnce(
eventClass: KClass<out E>, eventClass: KClass<out E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
...@@ -321,7 +321,7 @@ fun <E : Event> CoroutineScope.subscribeOnce( ...@@ -321,7 +321,7 @@ fun <E : Event> CoroutineScope.subscribeOnce(
@JvmSynthetic @JvmSynthetic
@LowPriorityInOverloadResolution @LowPriorityInOverloadResolution
@JvmName("subscribe1") @JvmName("subscribe1")
inline fun <reified E : Event> CoroutineScope.subscribe( public inline fun <reified E : Event> CoroutineScope.subscribe(
crossinline handler: (E) -> ListeningStatus, crossinline handler: (E) -> ListeningStatus,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
concurrency: Listener.ConcurrencyKind = CONCURRENT, concurrency: Listener.ConcurrencyKind = CONCURRENT,
...@@ -342,7 +342,7 @@ inline fun <reified E : Event> CoroutineScope.subscribe( ...@@ -342,7 +342,7 @@ inline fun <reified E : Event> CoroutineScope.subscribe(
@JvmSynthetic @JvmSynthetic
@LowPriorityInOverloadResolution @LowPriorityInOverloadResolution
@JvmName("subscribe2") @JvmName("subscribe2")
inline fun <reified E : Event> CoroutineScope.subscribe( public inline fun <reified E : Event> CoroutineScope.subscribe(
crossinline handler: E.(E) -> ListeningStatus, crossinline handler: E.(E) -> ListeningStatus,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
concurrency: Listener.ConcurrencyKind = CONCURRENT, concurrency: Listener.ConcurrencyKind = CONCURRENT,
...@@ -363,7 +363,7 @@ inline fun <reified E : Event> CoroutineScope.subscribe( ...@@ -363,7 +363,7 @@ inline fun <reified E : Event> CoroutineScope.subscribe(
@JvmSynthetic @JvmSynthetic
@LowPriorityInOverloadResolution @LowPriorityInOverloadResolution
@JvmName("subscribe1") @JvmName("subscribe1")
inline fun <reified E : Event> CoroutineScope.subscribe( public inline fun <reified E : Event> CoroutineScope.subscribe(
crossinline handler: suspend (E) -> ListeningStatus, crossinline handler: suspend (E) -> ListeningStatus,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
concurrency: Listener.ConcurrencyKind = CONCURRENT, concurrency: Listener.ConcurrencyKind = CONCURRENT,
...@@ -384,7 +384,7 @@ inline fun <reified E : Event> CoroutineScope.subscribe( ...@@ -384,7 +384,7 @@ inline fun <reified E : Event> CoroutineScope.subscribe(
@JvmSynthetic @JvmSynthetic
@LowPriorityInOverloadResolution @LowPriorityInOverloadResolution
@JvmName("subscribe3") @JvmName("subscribe3")
inline fun <reified E : Event> CoroutineScope.subscribe( public inline fun <reified E : Event> CoroutineScope.subscribe(
crossinline handler: suspend E.(E) -> ListeningStatus, crossinline handler: suspend E.(E) -> ListeningStatus,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
concurrency: Listener.ConcurrencyKind = CONCURRENT, concurrency: Listener.ConcurrencyKind = CONCURRENT,
...@@ -410,7 +410,7 @@ inline fun <reified E : Event> CoroutineScope.subscribe( ...@@ -410,7 +410,7 @@ inline fun <reified E : Event> CoroutineScope.subscribe(
@JvmSynthetic @JvmSynthetic
@LowPriorityInOverloadResolution @LowPriorityInOverloadResolution
@JvmName("subscribeAlways1") @JvmName("subscribeAlways1")
inline fun <reified E : Event> CoroutineScope.subscribeAlways( public inline fun <reified E : Event> CoroutineScope.subscribeAlways(
crossinline handler: (E) -> Unit, crossinline handler: (E) -> Unit,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
concurrency: Listener.ConcurrencyKind = CONCURRENT, concurrency: Listener.ConcurrencyKind = CONCURRENT,
...@@ -429,7 +429,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeAlways( ...@@ -429,7 +429,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeAlways(
@JvmSynthetic @JvmSynthetic
@LowPriorityInOverloadResolution @LowPriorityInOverloadResolution
@JvmName("subscribeAlways1") @JvmName("subscribeAlways1")
inline fun <reified E : Event> CoroutineScope.subscribeAlways( public inline fun <reified E : Event> CoroutineScope.subscribeAlways(
crossinline handler: E.(E) -> Unit, crossinline handler: E.(E) -> Unit,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
concurrency: Listener.ConcurrencyKind = CONCURRENT, concurrency: Listener.ConcurrencyKind = CONCURRENT,
...@@ -448,7 +448,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeAlways( ...@@ -448,7 +448,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeAlways(
@JvmSynthetic @JvmSynthetic
@LowPriorityInOverloadResolution @LowPriorityInOverloadResolution
@JvmName("subscribe4") @JvmName("subscribe4")
inline fun <reified E : Event> CoroutineScope.subscribeAlways( public inline fun <reified E : Event> CoroutineScope.subscribeAlways(
crossinline handler: suspend (E) -> Unit, crossinline handler: suspend (E) -> Unit,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
concurrency: Listener.ConcurrencyKind = CONCURRENT, concurrency: Listener.ConcurrencyKind = CONCURRENT,
...@@ -467,7 +467,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeAlways( ...@@ -467,7 +467,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeAlways(
@JvmSynthetic @JvmSynthetic
@LowPriorityInOverloadResolution @LowPriorityInOverloadResolution
@JvmName("subscribe1") @JvmName("subscribe1")
inline fun <reified E : Event> CoroutineScope.subscribeAlways( public inline fun <reified E : Event> CoroutineScope.subscribeAlways(
crossinline handler: suspend E.(E) -> Unit, crossinline handler: suspend E.(E) -> Unit,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
concurrency: Listener.ConcurrencyKind = CONCURRENT, concurrency: Listener.ConcurrencyKind = CONCURRENT,
......
...@@ -45,7 +45,7 @@ import kotlin.reflect.KClass ...@@ -45,7 +45,7 @@ import kotlin.reflect.KClass
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
inline fun <reified E : BotEvent> Bot.subscribe( public inline fun <reified E : BotEvent> Bot.subscribe(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED, concurrency: Listener.ConcurrencyKind = LOCKED,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
...@@ -59,7 +59,7 @@ inline fun <reified E : BotEvent> Bot.subscribe( ...@@ -59,7 +59,7 @@ inline fun <reified E : BotEvent> Bot.subscribe(
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
fun <E : BotEvent> Bot.subscribe( public fun <E : BotEvent> Bot.subscribe(
eventClass: KClass<E>, eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED, concurrency: Listener.ConcurrencyKind = LOCKED,
...@@ -82,7 +82,7 @@ fun <E : BotEvent> Bot.subscribe( ...@@ -82,7 +82,7 @@ fun <E : BotEvent> Bot.subscribe(
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
inline fun <reified E : BotEvent> Bot.subscribeAlways( public inline fun <reified E : BotEvent> Bot.subscribeAlways(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = CONCURRENT, concurrency: Listener.ConcurrencyKind = CONCURRENT,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
...@@ -95,7 +95,7 @@ inline fun <reified E : BotEvent> Bot.subscribeAlways( ...@@ -95,7 +95,7 @@ inline fun <reified E : BotEvent> Bot.subscribeAlways(
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
fun <E : BotEvent> Bot.subscribeAlways( public fun <E : BotEvent> Bot.subscribeAlways(
eventClass: KClass<E>, eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = CONCURRENT, concurrency: Listener.ConcurrencyKind = CONCURRENT,
...@@ -114,7 +114,7 @@ fun <E : BotEvent> Bot.subscribeAlways( ...@@ -114,7 +114,7 @@ fun <E : BotEvent> Bot.subscribeAlways(
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
inline fun <reified E : BotEvent> Bot.subscribeOnce( public inline fun <reified E : BotEvent> Bot.subscribeOnce(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
noinline listener: suspend E.(E) -> Unit noinline listener: suspend E.(E) -> Unit
...@@ -126,7 +126,7 @@ inline fun <reified E : BotEvent> Bot.subscribeOnce( ...@@ -126,7 +126,7 @@ inline fun <reified E : BotEvent> Bot.subscribeOnce(
"Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.",
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
fun <E : BotEvent> Bot.subscribeOnce( public fun <E : BotEvent> Bot.subscribeOnce(
eventClass: KClass<E>, eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
priority: Listener.EventPriority = NORMAL, priority: Listener.EventPriority = NORMAL,
...@@ -149,7 +149,7 @@ fun <E : BotEvent> Bot.subscribeOnce( ...@@ -149,7 +149,7 @@ fun <E : BotEvent> Bot.subscribeOnce(
@JvmSynthetic @JvmSynthetic
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@Suppress("unused") @Suppress("unused")
inline fun <reified E : Event> CoroutineScope.subscribeDeprecated( public inline fun <reified E : Event> CoroutineScope.subscribeDeprecated(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED, concurrency: Listener.ConcurrencyKind = LOCKED,
noinline handler: suspend E.(E) -> ListeningStatus noinline handler: suspend E.(E) -> ListeningStatus
...@@ -165,7 +165,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeDeprecated( ...@@ -165,7 +165,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeDeprecated(
@JvmSynthetic @JvmSynthetic
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@Suppress("unused") @Suppress("unused")
fun <E : Event> CoroutineScope.subscribeDeprecated( public fun <E : Event> CoroutineScope.subscribeDeprecated(
eventClass: KClass<E>, eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED, concurrency: Listener.ConcurrencyKind = LOCKED,
...@@ -183,7 +183,7 @@ fun <E : Event> CoroutineScope.subscribeDeprecated( ...@@ -183,7 +183,7 @@ fun <E : Event> CoroutineScope.subscribeDeprecated(
@JvmSynthetic @JvmSynthetic
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@Suppress("unused") @Suppress("unused")
inline fun <reified E : Event> CoroutineScope.subscribeAlwaysDeprecated( public inline fun <reified E : Event> CoroutineScope.subscribeAlwaysDeprecated(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED, concurrency: Listener.ConcurrencyKind = LOCKED,
noinline listener: suspend E.(E) -> Unit noinline listener: suspend E.(E) -> Unit
...@@ -199,7 +199,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeAlwaysDeprecated( ...@@ -199,7 +199,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeAlwaysDeprecated(
@JvmSynthetic @JvmSynthetic
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@Suppress("unused") @Suppress("unused")
fun <E : Event> CoroutineScope.subscribeAlwaysDeprecated( public fun <E : Event> CoroutineScope.subscribeAlwaysDeprecated(
eventClass: KClass<E>, eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED, concurrency: Listener.ConcurrencyKind = LOCKED,
...@@ -217,7 +217,7 @@ fun <E : Event> CoroutineScope.subscribeAlwaysDeprecated( ...@@ -217,7 +217,7 @@ fun <E : Event> CoroutineScope.subscribeAlwaysDeprecated(
@JvmSynthetic @JvmSynthetic
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@Suppress("unused") @Suppress("unused")
inline fun <reified E : Event> CoroutineScope.subscribeOnceDeprecated( public inline fun <reified E : Event> CoroutineScope.subscribeOnceDeprecated(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
noinline listener: suspend E.(E) -> Unit noinline listener: suspend E.(E) -> Unit
): Listener<E> = subscribeOnce( ): Listener<E> = subscribeOnce(
...@@ -231,7 +231,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeOnceDeprecated( ...@@ -231,7 +231,7 @@ inline fun <reified E : Event> CoroutineScope.subscribeOnceDeprecated(
@JvmSynthetic @JvmSynthetic
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@Suppress("unused") @Suppress("unused")
fun <E : Event> CoroutineScope.subscribeOnceDeprecated( public fun <E : Event> CoroutineScope.subscribeOnceDeprecated(
eventClass: KClass<E>, eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
listener: suspend E.(E) -> Unit listener: suspend E.(E) -> Unit
...@@ -247,7 +247,7 @@ fun <E : Event> CoroutineScope.subscribeOnceDeprecated( ...@@ -247,7 +247,7 @@ fun <E : Event> CoroutineScope.subscribeOnceDeprecated(
@JvmName("subscribeAlwaysForBot") @JvmName("subscribeAlwaysForBot")
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@Suppress("unused") @Suppress("unused")
inline fun <reified E : BotEvent> Bot.subscribeDeprecated( public inline fun <reified E : BotEvent> Bot.subscribeDeprecated(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED, concurrency: Listener.ConcurrencyKind = LOCKED,
noinline handler: suspend E.(E) -> ListeningStatus noinline handler: suspend E.(E) -> ListeningStatus
...@@ -263,7 +263,7 @@ inline fun <reified E : BotEvent> Bot.subscribeDeprecated( ...@@ -263,7 +263,7 @@ inline fun <reified E : BotEvent> Bot.subscribeDeprecated(
@JvmName("subscribe") @JvmName("subscribe")
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@Suppress("unused") @Suppress("unused")
fun <E : BotEvent> Bot.subscribeDeprecated( public fun <E : BotEvent> Bot.subscribeDeprecated(
eventClass: KClass<E>, eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED, concurrency: Listener.ConcurrencyKind = LOCKED,
...@@ -281,7 +281,7 @@ fun <E : BotEvent> Bot.subscribeDeprecated( ...@@ -281,7 +281,7 @@ fun <E : BotEvent> Bot.subscribeDeprecated(
@JvmName("subscribeAlwaysForBot1") @JvmName("subscribeAlwaysForBot1")
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@Suppress("unused") @Suppress("unused")
inline fun <reified E : BotEvent> Bot.subscribeAlwaysDeprecated( public inline fun <reified E : BotEvent> Bot.subscribeAlwaysDeprecated(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = CONCURRENT, concurrency: Listener.ConcurrencyKind = CONCURRENT,
noinline listener: suspend E.(E) -> Unit noinline listener: suspend E.(E) -> Unit
...@@ -297,7 +297,7 @@ inline fun <reified E : BotEvent> Bot.subscribeAlwaysDeprecated( ...@@ -297,7 +297,7 @@ inline fun <reified E : BotEvent> Bot.subscribeAlwaysDeprecated(
@JvmName("subscribeAlways") @JvmName("subscribeAlways")
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@Suppress("unused") @Suppress("unused")
fun <E : BotEvent> Bot.subscribeAlwaysDeprecated( public fun <E : BotEvent> Bot.subscribeAlwaysDeprecated(
eventClass: KClass<E>, eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = CONCURRENT, concurrency: Listener.ConcurrencyKind = CONCURRENT,
...@@ -315,7 +315,7 @@ fun <E : BotEvent> Bot.subscribeAlwaysDeprecated( ...@@ -315,7 +315,7 @@ fun <E : BotEvent> Bot.subscribeAlwaysDeprecated(
@JvmName("subscribeOnceForBot2") @JvmName("subscribeOnceForBot2")
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@Suppress("unused") @Suppress("unused")
inline fun <reified E : BotEvent> Bot.subscribeOnceDeprecated( public inline fun <reified E : BotEvent> Bot.subscribeOnceDeprecated(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
noinline listener: suspend E.(E) -> Unit noinline listener: suspend E.(E) -> Unit
): Listener<E> = subscribeOnce( ): Listener<E> = subscribeOnce(
...@@ -329,7 +329,7 @@ inline fun <reified E : BotEvent> Bot.subscribeOnceDeprecated( ...@@ -329,7 +329,7 @@ inline fun <reified E : BotEvent> Bot.subscribeOnceDeprecated(
@JvmName("subscribeOnce") @JvmName("subscribeOnce")
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@Suppress("unused") @Suppress("unused")
fun <E : BotEvent> Bot.subscribeOnceDeprecated( public fun <E : BotEvent> Bot.subscribeOnceDeprecated(
eventClass: KClass<E>, eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
listener: suspend E.(E) -> Unit listener: suspend E.(E) -> Unit
......
...@@ -13,10 +13,6 @@ import kotlinx.coroutines.Job ...@@ -13,10 +13,6 @@ import kotlinx.coroutines.Job
import net.mamoe.mirai.contact.Friend import net.mamoe.mirai.contact.Friend
import net.mamoe.mirai.contact.Group import net.mamoe.mirai.contact.Group
import net.mamoe.mirai.data.* import net.mamoe.mirai.data.*
import net.mamoe.mirai.event.events.BotInvitedJoinGroupRequestEvent
import net.mamoe.mirai.event.events.MemberJoinRequestEvent
import net.mamoe.mirai.event.events.NewFriendRequestEvent
import net.mamoe.mirai.message.data.Voice
import net.mamoe.mirai.utils.MiraiExperimentalAPI import net.mamoe.mirai.utils.MiraiExperimentalAPI
import net.mamoe.mirai.utils.WeakRef import net.mamoe.mirai.utils.WeakRef
...@@ -30,7 +26,7 @@ import net.mamoe.mirai.utils.WeakRef ...@@ -30,7 +26,7 @@ import net.mamoe.mirai.utils.WeakRef
@RequiresOptIn @RequiresOptIn
@Retention(AnnotationRetention.BINARY) @Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY) @Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
annotation class LowLevelAPI public annotation class LowLevelAPI
/** /**
* [Bot] 相关协议层低级 API. * [Bot] 相关协议层低级 API.
...@@ -42,7 +38,7 @@ annotation class LowLevelAPI ...@@ -42,7 +38,7 @@ annotation class LowLevelAPI
@MiraiExperimentalAPI @MiraiExperimentalAPI
@Suppress("FunctionName", "unused") @Suppress("FunctionName", "unused")
@LowLevelAPI @LowLevelAPI
interface LowLevelBotAPIAccessor { public interface LowLevelBotAPIAccessor {
/** /**
* 构造一个 [Friend] 对象. 它持有对 [Bot] 的弱引用([WeakRef]). * 构造一个 [Friend] 对象. 它持有对 [Bot] 的弱引用([WeakRef]).
* *
...@@ -50,20 +46,20 @@ interface LowLevelBotAPIAccessor { ...@@ -50,20 +46,20 @@ interface LowLevelBotAPIAccessor {
* 因此, 当 [Bot] 被关闭后, 这个对象也会被关闭. * 因此, 当 [Bot] 被关闭后, 这个对象也会被关闭.
*/ */
@LowLevelAPI @LowLevelAPI
fun _lowLevelNewFriend(friendInfo: FriendInfo): Friend public fun _lowLevelNewFriend(friendInfo: FriendInfo): Friend
/** /**
* 向服务器查询群列表. 返回值高 32 bits 为 uin, 低 32 bits 为 groupCode * 向服务器查询群列表. 返回值高 32 bits 为 uin, 低 32 bits 为 groupCode
*/ */
@LowLevelAPI @LowLevelAPI
suspend fun _lowLevelQueryGroupList(): Sequence<Long> public suspend fun _lowLevelQueryGroupList(): Sequence<Long>
/** /**
* 向服务器查询群资料. 获得的仅为当前时刻的资料. * 向服务器查询群资料. 获得的仅为当前时刻的资料.
* 请优先使用 [Bot.getGroup] 然后查看群资料. * 请优先使用 [Bot.getGroup] 然后查看群资料.
*/ */
@LowLevelAPI @LowLevelAPI
suspend fun _lowLevelQueryGroupInfo(groupCode: Long): GroupInfo public suspend fun _lowLevelQueryGroupInfo(groupCode: Long): GroupInfo
/** /**
* 向服务器查询群成员列表. * 向服务器查询群成员列表.
...@@ -74,7 +70,11 @@ interface LowLevelBotAPIAccessor { ...@@ -74,7 +70,11 @@ interface LowLevelBotAPIAccessor {
* @see Group.calculateGroupUinByGroupCode 使用 groupCode 计算 groupUin * @see Group.calculateGroupUinByGroupCode 使用 groupCode 计算 groupUin
*/ */
@LowLevelAPI @LowLevelAPI
suspend fun _lowLevelQueryGroupMemberList(groupUin: Long, groupCode: Long, ownerId: Long): Sequence<MemberInfo> public suspend fun _lowLevelQueryGroupMemberList(
groupUin: Long,
groupCode: Long,
ownerId: Long
): Sequence<MemberInfo>
/** /**
* 获取群公告列表 * 获取群公告列表
...@@ -82,7 +82,7 @@ interface LowLevelBotAPIAccessor { ...@@ -82,7 +82,7 @@ interface LowLevelBotAPIAccessor {
*/ */
@LowLevelAPI @LowLevelAPI
@MiraiExperimentalAPI @MiraiExperimentalAPI
suspend fun _lowLevelGetAnnouncements(groupId: Long, page: Int = 1, amount: Int = 10): GroupAnnouncementList public suspend fun _lowLevelGetAnnouncements(groupId: Long, page: Int = 1, amount: Int = 10): GroupAnnouncementList
/** /**
* 发送群公告 * 发送群公告
...@@ -91,7 +91,7 @@ interface LowLevelBotAPIAccessor { ...@@ -91,7 +91,7 @@ interface LowLevelBotAPIAccessor {
*/ */
@LowLevelAPI @LowLevelAPI
@MiraiExperimentalAPI @MiraiExperimentalAPI
suspend fun _lowLevelSendAnnouncement(groupId: Long, announcement: GroupAnnouncement): String public suspend fun _lowLevelSendAnnouncement(groupId: Long, announcement: GroupAnnouncement): String
/** /**
...@@ -100,7 +100,7 @@ interface LowLevelBotAPIAccessor { ...@@ -100,7 +100,7 @@ interface LowLevelBotAPIAccessor {
*/ */
@LowLevelAPI @LowLevelAPI
@MiraiExperimentalAPI @MiraiExperimentalAPI
suspend fun _lowLevelDeleteAnnouncement(groupId: Long, fid: String) public suspend fun _lowLevelDeleteAnnouncement(groupId: Long, fid: String)
/** /**
* 获取一条群公告 * 获取一条群公告
...@@ -108,7 +108,7 @@ interface LowLevelBotAPIAccessor { ...@@ -108,7 +108,7 @@ interface LowLevelBotAPIAccessor {
*/ */
@LowLevelAPI @LowLevelAPI
@MiraiExperimentalAPI @MiraiExperimentalAPI
suspend fun _lowLevelGetAnnouncement(groupId: Long, fid: String): GroupAnnouncement public suspend fun _lowLevelGetAnnouncement(groupId: Long, fid: String): GroupAnnouncement
/** /**
...@@ -118,7 +118,7 @@ interface LowLevelBotAPIAccessor { ...@@ -118,7 +118,7 @@ interface LowLevelBotAPIAccessor {
*/ */
@LowLevelAPI @LowLevelAPI
@MiraiExperimentalAPI @MiraiExperimentalAPI
suspend fun _lowLevelGetGroupActiveData(groupId: Long, page: Int = -1): GroupActiveData public suspend fun _lowLevelGetGroupActiveData(groupId: Long, page: Int = -1): GroupActiveData
/** /**
...@@ -126,7 +126,7 @@ interface LowLevelBotAPIAccessor { ...@@ -126,7 +126,7 @@ interface LowLevelBotAPIAccessor {
*/ */
@LowLevelAPI @LowLevelAPI
@MiraiExperimentalAPI @MiraiExperimentalAPI
suspend fun _lowLevelSolveNewFriendRequestEvent( public suspend fun _lowLevelSolveNewFriendRequestEvent(
eventId: Long, eventId: Long,
fromId: Long, fromId: Long,
fromNick: String, fromNick: String,
...@@ -139,7 +139,7 @@ interface LowLevelBotAPIAccessor { ...@@ -139,7 +139,7 @@ interface LowLevelBotAPIAccessor {
*/ */
@LowLevelAPI @LowLevelAPI
@MiraiExperimentalAPI @MiraiExperimentalAPI
suspend fun _lowLevelSolveBotInvitedJoinGroupRequestEvent( public suspend fun _lowLevelSolveBotInvitedJoinGroupRequestEvent(
eventId: Long, eventId: Long,
invitorId: Long, invitorId: Long,
groupId: Long, groupId: Long,
...@@ -151,7 +151,7 @@ interface LowLevelBotAPIAccessor { ...@@ -151,7 +151,7 @@ interface LowLevelBotAPIAccessor {
*/ */
@LowLevelAPI @LowLevelAPI
@MiraiExperimentalAPI @MiraiExperimentalAPI
suspend fun _lowLevelSolveMemberJoinRequestEvent( public suspend fun _lowLevelSolveMemberJoinRequestEvent(
eventId: Long, eventId: Long,
fromId: Long, fromId: Long,
fromNick: String, fromNick: String,
...@@ -163,10 +163,8 @@ interface LowLevelBotAPIAccessor { ...@@ -163,10 +163,8 @@ interface LowLevelBotAPIAccessor {
/** /**
* 查询语音的下载连接 * 查询语音的下载连接
* */
* */
@LowLevelAPI @LowLevelAPI
@MiraiExperimentalAPI @MiraiExperimentalAPI
suspend fun _lowLevelQueryGroupVoiceDownloadUrl(md5: ByteArray, groupId: Long, dstUin: Long): String public suspend fun _lowLevelQueryGroupVoiceDownloadUrl(md5: ByteArray, groupId: Long, dstUin: Long): String
} }
...@@ -25,10 +25,10 @@ import net.mamoe.mirai.utils.PlannedRemoval ...@@ -25,10 +25,10 @@ import net.mamoe.mirai.utils.PlannedRemoval
* *
* @see MessageEvent * @see MessageEvent
*/ */
class FriendMessageEvent constructor( public class FriendMessageEvent constructor(
override val sender: Friend, public override val sender: Friend,
override val message: MessageChain, public override val message: MessageChain,
override val time: Int public override val time: Int
) : @PlannedRemoval("1.2.0") FriendMessage(), BroadcastControllable { ) : @PlannedRemoval("1.2.0") FriendMessage(), BroadcastControllable {
init { init {
val source = val source =
...@@ -36,10 +36,10 @@ class FriendMessageEvent constructor( ...@@ -36,10 +36,10 @@ class FriendMessageEvent constructor(
check(source is OnlineMessageSource.Incoming.FromFriend) { "source provided to a FriendMessage must be an instance of OnlineMessageSource.Incoming.FromFriend" } check(source is OnlineMessageSource.Incoming.FromFriend) { "source provided to a FriendMessage must be an instance of OnlineMessageSource.Incoming.FromFriend" }
} }
override val bot: Bot get() = sender.bot public override val bot: Bot get() = sender.bot
override val subject: Friend get() = sender public override val subject: Friend get() = sender
override val senderName: String get() = sender.nick public override val senderName: String get() = sender.nick
override val source: OnlineMessageSource.Incoming.FromFriend get() = message.source as OnlineMessageSource.Incoming.FromFriend public override val source: OnlineMessageSource.Incoming.FromFriend get() = message.source as OnlineMessageSource.Incoming.FromFriend
override fun toString(): String = "FriendMessageEvent(sender=${sender.id}, message=$message)" public override fun toString(): String = "FriendMessageEvent(sender=${sender.id}, message=$message)"
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE * https://github.com/mamoe/mirai/blob/master/LICENSE
*/ */
@file:Suppress("DEPRECATION_ERROR", "unused", "NOTHING_TO_INLINE") @file:Suppress("DEPRECATION_ERROR", "unused", "NOTHING_TO_INLINE", "MemberVisibilityCanBePrivate")
package net.mamoe.mirai.message package net.mamoe.mirai.message
...@@ -24,30 +24,30 @@ import net.mamoe.mirai.utils.PlannedRemoval ...@@ -24,30 +24,30 @@ import net.mamoe.mirai.utils.PlannedRemoval
* *
* @see MessageEvent * @see MessageEvent
*/ */
class GroupMessageEvent( public class GroupMessageEvent(
override val senderName: String, public override val senderName: String,
/** /**
* 发送方权限. * 发送方权限.
*/ */
val permission: MemberPermission, public val permission: MemberPermission,
override val sender: Member, public override val sender: Member,
override val message: MessageChain, public override val message: MessageChain,
override val time: Int public override val time: Int
) : @PlannedRemoval("1.2.0") GroupMessage(), Event { ) : @PlannedRemoval("1.2.0") GroupMessage(), Event {
init { init {
val source = message[MessageSource] ?: error("Cannot find MessageSource from message") val source = message[MessageSource] ?: error("Cannot find MessageSource from message")
check(source is OnlineMessageSource.Incoming.FromGroup) { "source provided to a GroupMessage must be an instance of OnlineMessageSource.Incoming.FromGroup" } check(source is OnlineMessageSource.Incoming.FromGroup) { "source provided to a GroupMessage must be an instance of OnlineMessageSource.Incoming.FromGroup" }
} }
override val group: Group get() = sender.group public override val group: Group get() = sender.group
override val bot: Bot get() = sender.bot public override val bot: Bot get() = sender.bot
override val subject: Group get() = group public override val subject: Group get() = group
override val source: OnlineMessageSource.Incoming.FromGroup get() = message.source as OnlineMessageSource.Incoming.FromGroup public override val source: OnlineMessageSource.Incoming.FromGroup get() = message.source as OnlineMessageSource.Incoming.FromGroup
inline fun At.asMember(): Member = group[this.target] public inline fun At.asMember(): Member = group[this.target]
override fun toString(): String = public override fun toString(): String =
"GroupMessageEvent(group=${group.id}, senderName=$senderName, sender=${sender.id}, permission=${permission.name}, message=$message)" "GroupMessageEvent(group=${group.id}, senderName=$senderName, sender=${sender.id}, permission=${permission.name}, message=$message)"
} }
\ No newline at end of file
...@@ -46,13 +46,13 @@ import kotlin.jvm.JvmSynthetic ...@@ -46,13 +46,13 @@ import kotlin.jvm.JvmSynthetic
* @see isContextIdenticalWith 判断语境是否相同 * @see isContextIdenticalWith 判断语境是否相同
*/ */
@Suppress("DEPRECATION_ERROR") @Suppress("DEPRECATION_ERROR")
abstract class MessageEvent : @PlannedRemoval("1.2.0") ContactMessage(), public abstract class MessageEvent : @PlannedRemoval("1.2.0") ContactMessage(),
BotEvent, MessageEventExtensions<User, Contact> { BotEvent, MessageEventExtensions<User, Contact> {
/** /**
* 与这个消息事件相关的 [Bot] * 与这个消息事件相关的 [Bot]
*/ */
abstract override val bot: Bot public abstract override val bot: Bot
/** /**
* 消息事件主体. * 消息事件主体.
...@@ -63,19 +63,19 @@ abstract class MessageEvent : @PlannedRemoval("1.2.0") ContactMessage(), ...@@ -63,19 +63,19 @@ abstract class MessageEvent : @PlannedRemoval("1.2.0") ContactMessage(),
* *
* 在回复消息时, 可通过 [subject] 作为回复对象 * 在回复消息时, 可通过 [subject] 作为回复对象
*/ */
abstract override val subject: Contact public abstract override val subject: Contact
/** /**
* 发送人. * 发送人.
* *
* 在好友消息时为 [Friend] 的实例, 在群消息时为 [Member] 的实例 * 在好友消息时为 [Friend] 的实例, 在群消息时为 [Member] 的实例
*/ */
abstract override val sender: User public abstract override val sender: User
/** /**
* 发送人名称 * 发送人名称
*/ */
abstract override val senderName: String public abstract override val senderName: String
/** /**
* 消息内容. * 消息内容.
...@@ -83,20 +83,20 @@ abstract class MessageEvent : @PlannedRemoval("1.2.0") ContactMessage(), ...@@ -83,20 +83,20 @@ abstract class MessageEvent : @PlannedRemoval("1.2.0") ContactMessage(),
* 第一个元素一定为 [MessageSource], 存储此消息的发送人, 发送时间, 收信人, 消息 id 等数据. * 第一个元素一定为 [MessageSource], 存储此消息的发送人, 发送时间, 收信人, 消息 id 等数据.
* 随后的元素为拥有顺序的真实消息内容. * 随后的元素为拥有顺序的真实消息内容.
*/ */
abstract override val message: MessageChain public abstract override val message: MessageChain
/** 消息发送时间 (由服务器提供, 可能与本地有时差) */ /** 消息发送时间 (由服务器提供, 可能与本地有时差) */
abstract override val time: Int public abstract override val time: Int
/** /**
* 消息源. 来自 [message] 的第一个元素, * 消息源. 来自 [message] 的第一个元素,
*/ */
override val source: OnlineMessageSource.Incoming get() = message.source as OnlineMessageSource.Incoming public override val source: OnlineMessageSource.Incoming get() = message.source as OnlineMessageSource.Incoming
} }
/** 消息事件的扩展函数 */ /** 消息事件的扩展函数 */
@Suppress("EXPOSED_SUPER_INTERFACE") // Functions are visible @Suppress("EXPOSED_SUPER_INTERFACE") // Functions are visible
interface MessageEventExtensions<out TSender : User, out TSubject : Contact> : public interface MessageEventExtensions<out TSender : User, out TSubject : Contact> :
MessageEventPlatformExtensions<TSender, TSubject> { MessageEventPlatformExtensions<TSender, TSubject> {
// region 发送 Message // region 发送 Message
...@@ -107,29 +107,29 @@ interface MessageEventExtensions<out TSender : User, out TSubject : Contact> : ...@@ -107,29 +107,29 @@ interface MessageEventExtensions<out TSender : User, out TSubject : Contact> :
* 对于群消息事件, 这个方法将会给群 ([subject]) 发送消息 * 对于群消息事件, 这个方法将会给群 ([subject]) 发送消息
*/ */
@JvmSynthetic @JvmSynthetic
suspend inline fun reply(message: Message): MessageReceipt<TSubject> = public suspend inline fun reply(message: Message): MessageReceipt<TSubject> =
subject.sendMessage(message.asMessageChain()) as MessageReceipt<TSubject> subject.sendMessage(message.asMessageChain()) as MessageReceipt<TSubject>
@JvmSynthetic @JvmSynthetic
suspend inline fun reply(plain: String): MessageReceipt<TSubject> = public suspend inline fun reply(plain: String): MessageReceipt<TSubject> =
subject.sendMessage(plain.toMessage().asMessageChain()) as MessageReceipt<TSubject> subject.sendMessage(plain.toMessage().asMessageChain()) as MessageReceipt<TSubject>
// endregion // endregion
@JvmSynthetic @JvmSynthetic
suspend inline fun ExternalImage.upload(): Image = this.upload(subject) public suspend inline fun ExternalImage.upload(): Image = this.upload(subject)
@JvmSynthetic @JvmSynthetic
suspend inline fun ExternalImage.send(): MessageReceipt<TSubject> = this.sendTo(subject) public suspend inline fun ExternalImage.send(): MessageReceipt<TSubject> = this.sendTo(subject)
@JvmSynthetic @JvmSynthetic
suspend inline fun Image.send(): MessageReceipt<TSubject> = this.sendTo(subject) public suspend inline fun Image.send(): MessageReceipt<TSubject> = this.sendTo(subject)
@JvmSynthetic @JvmSynthetic
suspend inline fun Message.send(): MessageReceipt<TSubject> = this.sendTo(subject) public suspend inline fun Message.send(): MessageReceipt<TSubject> = this.sendTo(subject)
@JvmSynthetic @JvmSynthetic
suspend inline fun String.send(): MessageReceipt<TSubject> = this.toMessage().sendTo(subject) public suspend inline fun String.send(): MessageReceipt<TSubject> = this.toMessage().sendTo(subject)
// region 引用回复 // region 引用回复
/** /**
...@@ -138,17 +138,18 @@ interface MessageEventExtensions<out TSender : User, out TSubject : Contact> : ...@@ -138,17 +138,18 @@ interface MessageEventExtensions<out TSender : User, out TSubject : Contact> :
* 对于群消息事件, 这个方法将会给群 ([subject]) 发送消息 * 对于群消息事件, 这个方法将会给群 ([subject]) 发送消息
*/ */
@JvmSynthetic @JvmSynthetic
suspend inline fun quoteReply(message: MessageChain): MessageReceipt<TSubject> = public suspend inline fun quoteReply(message: MessageChain): MessageReceipt<TSubject> =
reply(this.message.quote() + message) reply(this.message.quote() + message)
@JvmSynthetic @JvmSynthetic
suspend inline fun quoteReply(message: Message): MessageReceipt<TSubject> = reply(this.message.quote() + message) public suspend inline fun quoteReply(message: Message): MessageReceipt<TSubject> =
reply(this.message.quote() + message)
@JvmSynthetic @JvmSynthetic
suspend inline fun quoteReply(plain: String): MessageReceipt<TSubject> = reply(this.message.quote() + plain) public suspend inline fun quoteReply(plain: String): MessageReceipt<TSubject> = reply(this.message.quote() + plain)
@JvmSynthetic @JvmSynthetic
inline fun At.isBot(): Boolean = target == bot.id public inline fun At.isBot(): Boolean = target == bot.id
/** /**
...@@ -156,7 +157,7 @@ interface MessageEventExtensions<out TSender : User, out TSubject : Contact> : ...@@ -156,7 +157,7 @@ interface MessageEventExtensions<out TSender : User, out TSubject : Contact> :
* @return "http://gchat.qpic.cn/gchatpic_new/..." * @return "http://gchat.qpic.cn/gchatpic_new/..."
*/ */
@JvmSynthetic @JvmSynthetic
suspend inline fun Image.url(): String = this@url.queryUrl() public suspend inline fun Image.url(): String = this@url.queryUrl()
} }
/** 一个消息事件在各平台的相关扩展. 请使用 [MessageEventExtensions] */ /** 一个消息事件在各平台的相关扩展. 请使用 [MessageEventExtensions] */
...@@ -177,14 +178,15 @@ internal expect interface MessageEventPlatformExtensions<out TSender : User, out ...@@ -177,14 +178,15 @@ internal expect interface MessageEventPlatformExtensions<out TSender : User, out
replaceWith = ReplaceWith("MessageEvent", "net.mamoe.mirai.message.MessageEvent"), replaceWith = ReplaceWith("MessageEvent", "net.mamoe.mirai.message.MessageEvent"),
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
abstract class MessagePacketBase<out TSender : User, out TSubject : Contact> : Packet, BotEvent, AbstractEvent() { public abstract class MessagePacketBase<out TSender : User, out TSubject : Contact> : Packet, BotEvent,
AbstractEvent() {
abstract override val bot: Bot abstract override val bot: Bot
abstract val sender: User public abstract val sender: User
abstract val subject: Contact public abstract val subject: Contact
abstract val message: MessageChain public abstract val message: MessageChain
abstract val time: Int public abstract val time: Int
abstract val source: OnlineMessageSource.Incoming public abstract val source: OnlineMessageSource.Incoming
abstract val senderName: String public abstract val senderName: String
} }
@PlannedRemoval("1.2.0") @PlannedRemoval("1.2.0")
...@@ -194,7 +196,7 @@ abstract class MessagePacketBase<out TSender : User, out TSubject : Contact> : P ...@@ -194,7 +196,7 @@ abstract class MessagePacketBase<out TSender : User, out TSubject : Contact> : P
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
@Suppress("DEPRECATION_ERROR") @Suppress("DEPRECATION_ERROR")
abstract class MessagePacket : MessagePacketBase<User, Contact>(), public abstract class MessagePacket : MessagePacketBase<User, Contact>(),
BotEvent, MessageEventExtensions<User, Contact> { BotEvent, MessageEventExtensions<User, Contact> {
abstract override val bot: Bot abstract override val bot: Bot
abstract override val sender: User abstract override val sender: User
...@@ -212,7 +214,7 @@ abstract class MessagePacket : MessagePacketBase<User, Contact>(), ...@@ -212,7 +214,7 @@ abstract class MessagePacket : MessagePacketBase<User, Contact>(),
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
@Suppress("DEPRECATION_ERROR") @Suppress("DEPRECATION_ERROR")
abstract class ContactMessage : MessagePacket(), public abstract class ContactMessage : MessagePacket(),
BotEvent, MessageEventExtensions<User, Contact> { BotEvent, MessageEventExtensions<User, Contact> {
abstract override val bot: Bot abstract override val bot: Bot
abstract override val sender: User abstract override val sender: User
...@@ -230,7 +232,7 @@ abstract class ContactMessage : MessagePacket(), ...@@ -230,7 +232,7 @@ abstract class ContactMessage : MessagePacket(),
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
@Suppress("DEPRECATION_ERROR") @Suppress("DEPRECATION_ERROR")
abstract class FriendMessage : MessageEvent() { public abstract class FriendMessage : MessageEvent() {
abstract override val bot: Bot abstract override val bot: Bot
abstract override val sender: Friend abstract override val sender: Friend
abstract override val subject: Friend abstract override val subject: Friend
...@@ -247,8 +249,8 @@ abstract class FriendMessage : MessageEvent() { ...@@ -247,8 +249,8 @@ abstract class FriendMessage : MessageEvent() {
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
@Suppress("DEPRECATION_ERROR") @Suppress("DEPRECATION_ERROR")
abstract class GroupMessage : MessageEvent() { public abstract class GroupMessage : MessageEvent() {
abstract val group: Group public abstract val group: Group
abstract override val bot: Bot abstract override val bot: Bot
abstract override val sender: Member abstract override val sender: Member
abstract override val subject: Group abstract override val subject: Group
...@@ -264,13 +266,13 @@ abstract class GroupMessage : MessageEvent() { ...@@ -264,13 +266,13 @@ abstract class GroupMessage : MessageEvent() {
replaceWith = ReplaceWith("TempMessageEvent", "net.mamoe.mirai.message.TempMessageEvent"), replaceWith = ReplaceWith("TempMessageEvent", "net.mamoe.mirai.message.TempMessageEvent"),
level = DeprecationLevel.HIDDEN level = DeprecationLevel.HIDDEN
) )
abstract class TempMessage : MessageEvent() { public abstract class TempMessage : MessageEvent() {
abstract override val bot: Bot abstract override val bot: Bot
abstract override val sender: Member abstract override val sender: Member
abstract override val subject: Member abstract override val subject: Member
abstract override val message: MessageChain abstract override val message: MessageChain
abstract override val time: Int abstract override val time: Int
abstract override val source: OnlineMessageSource.Incoming.FromTemp abstract override val source: OnlineMessageSource.Incoming.FromTemp
abstract val group: Group public abstract val group: Group
abstract override val senderName: String abstract override val senderName: String
} }
\ No newline at end of file
...@@ -41,26 +41,26 @@ import kotlin.jvm.JvmSynthetic ...@@ -41,26 +41,26 @@ import kotlin.jvm.JvmSynthetic
* @see MessageReceipt.sourceId 源 id * @see MessageReceipt.sourceId 源 id
* @see MessageReceipt.sourceTime 源时间 * @see MessageReceipt.sourceTime 源时间
*/ */
open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The constructor is subject to change.") constructor( public open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The constructor is subject to change.") constructor(
/** /**
* 指代发送出去的消息. * 指代发送出去的消息.
*/ */
val source: OnlineMessageSource.Outgoing, public val source: OnlineMessageSource.Outgoing,
/** /**
* 发送目标, 为 [Group] 或 [Friend] 或 [Member] * 发送目标, 为 [Group] 或 [Friend] 或 [Member]
*/ */
val target: C, public val target: C,
/** /**
* @see Group.botAsMember * @see Group.botAsMember
*/ */
@MiraiExperimentalAPI("This is subject to change.") @MiraiExperimentalAPI("This is subject to change.")
val botAsMember: Member? public val botAsMember: Member?
) { ) {
/** /**
* 是否为发送给群的消息的回执 * 是否为发送给群的消息的回执
*/ */
val isToGroup: Boolean get() = target is Group public val isToGroup: Boolean get() = target is Group
/** /**
* 引用这条消息并回复. * 引用这条消息并回复.
...@@ -71,7 +71,7 @@ open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The constructo ...@@ -71,7 +71,7 @@ open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The constructo
*/ */
@JavaFriendlyAPI @JavaFriendlyAPI
@JvmName("quoteReply") @JvmName("quoteReply")
fun __quoteReplyBlockingForJava__(message: Message): MessageReceipt<C> { public fun __quoteReplyBlockingForJava__(message: Message): MessageReceipt<C> {
return runBlocking { return@runBlocking quoteReply(message) } return runBlocking { return@runBlocking quoteReply(message) }
} }
...@@ -82,7 +82,7 @@ open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The constructo ...@@ -82,7 +82,7 @@ open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The constructo
*/ */
@JavaFriendlyAPI @JavaFriendlyAPI
@JvmName("quoteReply") @JvmName("quoteReply")
fun __quoteReplyBlockingForJava__(message: String): MessageReceipt<C> { public fun __quoteReplyBlockingForJava__(message: String): MessageReceipt<C> {
return runBlocking { quoteReply(message) } return runBlocking { quoteReply(message) }
} }
...@@ -93,7 +93,7 @@ open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The constructo ...@@ -93,7 +93,7 @@ open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The constructo
*/ */
@JavaFriendlyAPI @JavaFriendlyAPI
@JvmName("recall") @JvmName("recall")
fun __recallBlockingForJava__() { public fun __recallBlockingForJava__() {
return runBlocking { recall() } return runBlocking { recall() }
} }
...@@ -104,7 +104,7 @@ open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The constructo ...@@ -104,7 +104,7 @@ open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The constructo
*/ */
@JavaFriendlyAPI @JavaFriendlyAPI
@JvmName("recallIn") @JvmName("recallIn")
fun __recallInBlockingForJava__(timeMillis: Long): Job { public fun __recallInBlockingForJava__(timeMillis: Long): Job {
return recallIn(timeMillis = timeMillis) return recallIn(timeMillis = timeMillis)
} }
...@@ -115,7 +115,7 @@ open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The constructo ...@@ -115,7 +115,7 @@ open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The constructo
*/ */
@JavaFriendlyAPI @JavaFriendlyAPI
@JvmName("quote") @JvmName("quote")
fun __quoteBlockingForJava__(): QuoteReply { public fun __quoteBlockingForJava__(): QuoteReply {
return this.quote() return this.quote()
} }
} }
...@@ -126,7 +126,7 @@ open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The constructo ...@@ -126,7 +126,7 @@ open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The constructo
* @see Bot.recall * @see Bot.recall
* @throws IllegalStateException 当此消息已经被撤回或正计划撤回时 * @throws IllegalStateException 当此消息已经被撤回或正计划撤回时
*/ */
suspend inline fun MessageReceipt<*>.recall() { public suspend inline fun MessageReceipt<*>.recall() {
return target.bot.recall(source) return target.bot.recall(source)
} }
...@@ -136,7 +136,7 @@ suspend inline fun MessageReceipt<*>.recall() { ...@@ -136,7 +136,7 @@ suspend inline fun MessageReceipt<*>.recall() {
* @param timeMillis 延迟时间, 单位为毫秒 * @param timeMillis 延迟时间, 单位为毫秒
* @throws IllegalStateException 当此消息已经被撤回或正计划撤回时 * @throws IllegalStateException 当此消息已经被撤回或正计划撤回时
*/ */
inline fun MessageReceipt<*>.recallIn( public inline fun MessageReceipt<*>.recallIn(
timeMillis: Long, timeMillis: Long,
coroutineContext: CoroutineContext = EmptyCoroutineContext coroutineContext: CoroutineContext = EmptyCoroutineContext
): Job = source.recallIn(timeMillis, coroutineContext) ): Job = source.recallIn(timeMillis, coroutineContext)
...@@ -147,14 +147,14 @@ inline fun MessageReceipt<*>.recallIn( ...@@ -147,14 +147,14 @@ inline fun MessageReceipt<*>.recallIn(
* @see MessageChain.quote 引用一条消息 * @see MessageChain.quote 引用一条消息
*/ */
@JvmSynthetic @JvmSynthetic
inline fun MessageReceipt<*>.quote(): QuoteReply = this.source.quote() public inline fun MessageReceipt<*>.quote(): QuoteReply = this.source.quote()
/** /**
* 引用这条消息并回复. * 引用这条消息并回复.
* @see MessageChain.quote 引用一条消息 * @see MessageChain.quote 引用一条消息
*/ */
@JvmSynthetic @JvmSynthetic
suspend inline fun <C : Contact> MessageReceipt<C>.quoteReply(message: Message): MessageReceipt<C> { public suspend inline fun <C : Contact> MessageReceipt<C>.quoteReply(message: Message): MessageReceipt<C> {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
return target.sendMessage(this.quote() + message) as MessageReceipt<C> return target.sendMessage(this.quote() + message) as MessageReceipt<C>
} }
...@@ -164,7 +164,7 @@ suspend inline fun <C : Contact> MessageReceipt<C>.quoteReply(message: Message): ...@@ -164,7 +164,7 @@ suspend inline fun <C : Contact> MessageReceipt<C>.quoteReply(message: Message):
* @see MessageChain.quote 引用一条消息 * @see MessageChain.quote 引用一条消息
*/ */
@JvmSynthetic @JvmSynthetic
suspend inline fun <C : Contact> MessageReceipt<C>.quoteReply(message: String): MessageReceipt<C> { public suspend inline fun <C : Contact> MessageReceipt<C>.quoteReply(message: String): MessageReceipt<C> {
return this.quoteReply(message.toMessage()) return this.quoteReply(message.toMessage())
} }
...@@ -175,7 +175,7 @@ suspend inline fun <C : Contact> MessageReceipt<C>.quoteReply(message: String): ...@@ -175,7 +175,7 @@ suspend inline fun <C : Contact> MessageReceipt<C>.quoteReply(message: String):
* @see MessageSource.id * @see MessageSource.id
*/ */
@get:JvmSynthetic @get:JvmSynthetic
inline val MessageReceipt<*>.sourceId: Int public inline val MessageReceipt<*>.sourceId: Int
get() = this.source.id get() = this.source.id
...@@ -185,7 +185,7 @@ inline val MessageReceipt<*>.sourceId: Int ...@@ -185,7 +185,7 @@ inline val MessageReceipt<*>.sourceId: Int
* @see MessageSource.id * @see MessageSource.id
*/ */
@get:JvmSynthetic @get:JvmSynthetic
inline val MessageReceipt<*>.sourceInternalId: Int public inline val MessageReceipt<*>.sourceInternalId: Int
get() = this.source.internalId get() = this.source.internalId
/** /**
...@@ -194,6 +194,6 @@ inline val MessageReceipt<*>.sourceInternalId: Int ...@@ -194,6 +194,6 @@ inline val MessageReceipt<*>.sourceInternalId: Int
* @see MessageSource.time * @see MessageSource.time
*/ */
@get:JvmSynthetic @get:JvmSynthetic
inline val MessageReceipt<*>.sourceTime: Int public inline val MessageReceipt<*>.sourceTime: Int
get() = this.source.time get() = this.source.time
...@@ -17,22 +17,22 @@ import net.mamoe.mirai.message.data.source ...@@ -17,22 +17,22 @@ import net.mamoe.mirai.message.data.source
* *
* @see MessageEvent * @see MessageEvent
*/ */
class TempMessageEvent( public class TempMessageEvent(
override val sender: Member, public override val sender: Member,
override val message: MessageChain, public override val message: MessageChain,
override val time: Int public override val time: Int
) : TempMessage(), BroadcastControllable { ) : TempMessage(), BroadcastControllable {
init { init {
val source = message[MessageSource] ?: error("Cannot find MessageSource from message") val source = message[MessageSource] ?: error("Cannot find MessageSource from message")
check(source is OnlineMessageSource.Incoming.FromTemp) { "source provided to a TempMessage must be an instance of OnlineMessageSource.Incoming.FromTemp" } check(source is OnlineMessageSource.Incoming.FromTemp) { "source provided to a TempMessage must be an instance of OnlineMessageSource.Incoming.FromTemp" }
} }
override val bot: Bot get() = sender.bot public override val bot: Bot get() = sender.bot
override val subject: Member get() = sender public override val subject: Member get() = sender
override val group: Group get() = sender.group public override val group: Group get() = sender.group
override val senderName: String get() = sender.nameCardOrNick public override val senderName: String get() = sender.nameCardOrNick
override val source: OnlineMessageSource.Incoming.FromTemp get() = message.source as OnlineMessageSource.Incoming.FromTemp public override val source: OnlineMessageSource.Incoming.FromTemp get() = message.source as OnlineMessageSource.Incoming.FromTemp
override fun toString(): String = public override fun toString(): String =
"TempMessageEvent(sender=${sender.id} from group(${sender.group.id}), message=$message)" "TempMessageEvent(sender=${sender.id} from group(${sender.group.id}), message=$message)"
} }
\ No newline at end of file
...@@ -33,12 +33,12 @@ import net.mamoe.mirai.utils.SinceMirai ...@@ -33,12 +33,12 @@ import net.mamoe.mirai.utils.SinceMirai
*/ */
@MiraiExperimentalAPI @MiraiExperimentalAPI
@SinceMirai("1.1.0") @SinceMirai("1.1.0")
interface CodableMessage : Message { public interface CodableMessage : Message {
/** /**
* 转换为 mirai 码. * 转换为 mirai 码.
* *
* @suppress 警告: 此 API 可能在任何时刻被改变 * @suppress 警告: 此 API 可能在任何时刻被改变
*/ */
@MiraiExperimentalAPI @MiraiExperimentalAPI
fun toMiraiCode(): String = this.toString() public fun toMiraiCode(): String = this.toString()
} }
\ No newline at end of file
...@@ -32,30 +32,30 @@ import kotlin.jvm.JvmSynthetic ...@@ -32,30 +32,30 @@ import kotlin.jvm.JvmSynthetic
* *
* @see AtAll 全体成员 * @see AtAll 全体成员
*/ */
data class At public data class At
@Suppress("DataClassPrivateConstructor") @Suppress("DataClassPrivateConstructor")
private constructor( private constructor(
val target: Long, public val target: Long,
/** /**
* "@群员名片" * "@群员名片"
*/ */
val display: String public val display: String
) : MessageContent, CodableMessage { ) : MessageContent, CodableMessage {
/** /**
* 构造一个 [At] 实例. 这是唯一的公开的构造方式. * 构造一个 [At] 实例. 这是唯一的公开的构造方式.
*/ */
constructor(member: Member) : this(member.id, "@${member.nameCardOrNick}") public constructor(member: Member) : this(member.id, "@${member.nameCardOrNick}")
override fun equals(other: Any?): Boolean { public override fun equals(other: Any?): Boolean {
return other is At && other.target == this.target && other.display == this.display return other is At && other.target == this.target && other.display == this.display
} }
override fun toString(): String = "[mirai:at:$target,$display]" public override fun toString(): String = "[mirai:at:$target,$display]"
override fun contentToString(): String = this.display public override fun contentToString(): String = this.display
companion object Key : Message.Key<At> { public companion object Key : Message.Key<At> {
override val typeName: String public override val typeName: String
get() = "At" get() = "At"
/** /**
...@@ -64,18 +64,18 @@ private constructor( ...@@ -64,18 +64,18 @@ private constructor(
@Suppress("FunctionName") @Suppress("FunctionName")
@JvmStatic @JvmStatic
@LowLevelAPI @LowLevelAPI
fun _lowLevelConstructAtInstance(target: Long, display: String): At = At(target, display) public fun _lowLevelConstructAtInstance(target: Long, display: String): At = At(target, display)
} }
// 自动为消息补充 " " // 自动为消息补充 " "
override fun followedBy(tail: Message): MessageChain { public override fun followedBy(tail: Message): MessageChain {
if (tail is PlainText && tail.content.startsWith(' ')) { if (tail is PlainText && tail.content.startsWith(' ')) {
return super<MessageContent>.followedBy(tail) return super<MessageContent>.followedBy(tail)
} }
return super<MessageContent>.followedBy(PlainText(" ")) + tail return super<MessageContent>.followedBy(PlainText(" ")) + tail
} }
override fun hashCode(): Int { public override fun hashCode(): Int {
var result = target.hashCode() var result = target.hashCode()
result = 31 * result + display.hashCode() result = 31 * result + display.hashCode()
return result return result
...@@ -88,4 +88,4 @@ private constructor( ...@@ -88,4 +88,4 @@ private constructor(
*/ */
@JvmSynthetic @JvmSynthetic
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun Member.at(): At = At(this) public inline fun Member.at(): At = At(this)
\ No newline at end of file \ No newline at end of file
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
@file:JvmMultifileClass @file:JvmMultifileClass
@file:JvmName("MessageUtils") @file:JvmName("MessageUtils")
@file:Suppress("MemberVisibilityCanBePrivate")
package net.mamoe.mirai.message.data package net.mamoe.mirai.message.data
...@@ -28,26 +29,26 @@ private const val displayA = "@全体成员" ...@@ -28,26 +29,26 @@ private const val displayA = "@全体成员"
* *
* @see At at 单个群成员 * @see At at 单个群成员
*/ */
object AtAll : public object AtAll :
Message.Key<AtAll>, Message.Key<AtAll>,
MessageContent, CodableMessage { MessageContent, CodableMessage {
const val display = displayA public const val display: String = displayA
override val typeName: String public override val typeName: String
get() = "AtAll" get() = "AtAll"
@Suppress("SpellCheckingInspection") @Suppress("SpellCheckingInspection")
override fun toString(): String = "[mirai:atall]" public override fun toString(): String = "[mirai:atall]"
override fun contentToString(): String = display public override fun contentToString(): String = display
override fun equals(other: Any?): Boolean { public override fun equals(other: Any?): Boolean {
return other === this return other === this
} }
override fun hashCode(): Int { public override fun hashCode(): Int {
return display.hashCode() return display.hashCode()
} }
// 自动为消息补充 " " // 自动为消息补充 " "
override fun followedBy(tail: Message): MessageChain { public override fun followedBy(tail: Message): MessageChain {
if (tail is PlainText && tail.content.startsWith(' ')) { if (tail is PlainText && tail.content.startsWith(' ')) {
return super<MessageContent>.followedBy(tail) return super<MessageContent>.followedBy(tail)
} }
......
...@@ -37,11 +37,11 @@ import kotlin.jvm.JvmOverloads ...@@ -37,11 +37,11 @@ import kotlin.jvm.JvmOverloads
* @see CustomMessageMetadata 自定义消息元数据 * @see CustomMessageMetadata 自定义消息元数据
*/ */
@MiraiExperimentalAPI @MiraiExperimentalAPI
sealed class CustomMessage : SingleMessage { public sealed class CustomMessage : SingleMessage {
/** /**
* 获取这个消息的工厂 * 获取这个消息的工厂
*/ */
abstract fun getFactory(): Factory<out CustomMessage> public abstract fun getFactory(): Factory<out CustomMessage>
/** /**
* 序列化和反序列化此消息的工厂, 将会自动注册. * 序列化和反序列化此消息的工厂, 将会自动注册.
...@@ -51,13 +51,13 @@ sealed class CustomMessage : SingleMessage { ...@@ -51,13 +51,13 @@ sealed class CustomMessage : SingleMessage {
* @see ProtoBufSerializerFactory 使用 [ProtoBuf] 作为序列模式的 [Factory] * @see ProtoBufSerializerFactory 使用 [ProtoBuf] 作为序列模式的 [Factory]
*/ */
@MiraiExperimentalAPI @MiraiExperimentalAPI
abstract class Factory<M : CustomMessage>( public abstract class Factory<M : CustomMessage>(
/** /**
* 此类型消息的名称. * 此类型消息的名称.
* 在发往服务器时使用此名称. * 在发往服务器时使用此名称.
* 应确保唯一且不变. * 应确保唯一且不变.
*/ */
final override val typeName: String public final override val typeName: String
) : Message.Key<M> { ) : Message.Key<M> {
init { init {
...@@ -69,51 +69,51 @@ sealed class CustomMessage : SingleMessage { ...@@ -69,51 +69,51 @@ sealed class CustomMessage : SingleMessage {
* 序列化此消息. * 序列化此消息.
*/ */
@Throws(Exception::class) @Throws(Exception::class)
abstract fun dump(message: @UnsafeVariance M): ByteArray public abstract fun dump(message: @UnsafeVariance M): ByteArray
/** /**
* 从 [input] 读取此消息. * 从 [input] 读取此消息.
*/ */
@Throws(Exception::class) @Throws(Exception::class)
abstract fun load(input: ByteArray): @UnsafeVariance M public abstract fun load(input: ByteArray): @UnsafeVariance M
} }
/** /**
* 使用 [ProtoBuf] 作为序列模式的 [Factory]. * 使用 [ProtoBuf] 作为序列模式的 [Factory].
* 推荐使用此工厂 * 推荐使用此工厂
*/ */
abstract class ProtoBufSerializerFactory<M : CustomMessage>(typeName: String) : public abstract class ProtoBufSerializerFactory<M : CustomMessage>(typeName: String) :
Factory<M>(typeName) { Factory<M>(typeName) {
/** /**
* 得到 [M] 的 [KSerializer]. * 得到 [M] 的 [KSerializer].
*/ */
abstract fun serializer(): KSerializer<M> public abstract fun serializer(): KSerializer<M>
override fun dump(message: M): ByteArray = ProtoBuf.dump(serializer(), message) public override fun dump(message: M): ByteArray = ProtoBuf.dump(serializer(), message)
override fun load(input: ByteArray): M = ProtoBuf.load(serializer(), input) public override fun load(input: ByteArray): M = ProtoBuf.load(serializer(), input)
} }
/** /**
* 使用 [Json] 作为序列模式的 [Factory] * 使用 [Json] 作为序列模式的 [Factory]
* 推荐在调试时使用此工厂 * 推荐在调试时使用此工厂
*/ */
abstract class JsonSerializerFactory<M : CustomMessage>(typeName: String) : public abstract class JsonSerializerFactory<M : CustomMessage>(typeName: String) :
Factory<M>(typeName) { Factory<M>(typeName) {
/** /**
* 得到 [M] 的 [KSerializer]. * 得到 [M] 的 [KSerializer].
*/ */
abstract fun serializer(): KSerializer<M> public abstract fun serializer(): KSerializer<M>
@OptIn(UnstableDefault::class) @OptIn(UnstableDefault::class)
open val json = Json(JsonConfiguration.Default) public open val json: Json = Json(JsonConfiguration.Default)
override fun dump(message: M): ByteArray = json.stringify(serializer(), message).toByteArray() public override fun dump(message: M): ByteArray = json.stringify(serializer(), message).toByteArray()
override fun load(input: ByteArray): M = json.parse(serializer(), String(input)) public override fun load(input: ByteArray): M = json.parse(serializer(), String(input))
} }
companion object Key : Message.Key<CustomMessage> { public companion object Key : Message.Key<CustomMessage> {
override val typeName: String get() = "CustomMessage" override val typeName: String get() = "CustomMessage"
private val factories: LockFreeLinkedList<Factory<*>> = LockFreeLinkedList() private val factories: LockFreeLinkedList<Factory<*>> = LockFreeLinkedList()
...@@ -127,14 +127,14 @@ sealed class CustomMessage : SingleMessage { ...@@ -127,14 +127,14 @@ sealed class CustomMessage : SingleMessage {
} }
@Serializable @Serializable
class CustomMessageFullData( private class CustomMessageFullData(
@ProtoId(1) val miraiVersionFlag: Int, @ProtoId(1) val miraiVersionFlag: Int,
@ProtoId(2) val typeName: String, @ProtoId(2) val typeName: String,
@ProtoId(3) val data: ByteArray @ProtoId(3) val data: ByteArray
) )
class CustomMessageFullDataDeserializeInternalException(cause: Throwable?) : RuntimeException(cause) public class CustomMessageFullDataDeserializeInternalException(cause: Throwable?) : RuntimeException(cause)
class CustomMessageFullDataDeserializeUserException(val body: ByteArray, cause: Throwable?) : public class CustomMessageFullDataDeserializeUserException(public val body: ByteArray, cause: Throwable?) :
RuntimeException(cause) RuntimeException(cause)
internal fun load(fullData: ByteReadPacket): CustomMessage? { internal fun load(fullData: ByteReadPacket): CustomMessage? {
...@@ -177,7 +177,7 @@ sealed class CustomMessage : SingleMessage { ...@@ -177,7 +177,7 @@ sealed class CustomMessage : SingleMessage {
*/ */
@MiraiExperimentalAPI @MiraiExperimentalAPI
@SinceMirai("1.1.0") @SinceMirai("1.1.0")
fun <T : CustomMessage> T.toByteArray(): ByteArray { public fun <T : CustomMessage> T.toByteArray(): ByteArray {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
return (this.getFactory() as CustomMessage.Factory<T>).dump(this) return (this.getFactory() as CustomMessage.Factory<T>).dump(this)
} }
...@@ -194,12 +194,12 @@ fun <T : CustomMessage> T.toByteArray(): ByteArray { ...@@ -194,12 +194,12 @@ fun <T : CustomMessage> T.toByteArray(): ByteArray {
* @see ConstrainSingle 可实现此接口以保证消息链中只存在一个元素 * @see ConstrainSingle 可实现此接口以保证消息链中只存在一个元素
*/ */
@MiraiExperimentalAPI @MiraiExperimentalAPI
abstract class CustomMessageMetadata : CustomMessage(), MessageMetadata { public abstract class CustomMessageMetadata : CustomMessage(), MessageMetadata {
companion object Key : Message.Key<CustomMessageMetadata> { public companion object Key : Message.Key<CustomMessageMetadata> {
override val typeName: String get() = "CustomMessageMetadata" override val typeName: String get() = "CustomMessageMetadata"
} }
open fun customToString(): ByteArray = customToStringImpl(this.getFactory()) public open fun customToString(): ByteArray = customToStringImpl(this.getFactory())
final override fun toString(): String = final override fun toString(): String =
"[mirai:custom:${getFactory().typeName}:${String(customToString())}]" "[mirai:custom:${getFactory().typeName}:${String(customToString())}]"
......
...@@ -23,8 +23,8 @@ import kotlin.jvm.JvmSynthetic ...@@ -23,8 +23,8 @@ import kotlin.jvm.JvmSynthetic
* *
* 一般不需要主动构造 [PlainText], [Message] 可直接与 [String] 相加. Java 用户请使用 [Message.plus] * 一般不需要主动构造 [PlainText], [Message] 可直接与 [String] 相加. Java 用户请使用 [Message.plus]
*/ */
data class PlainText( public data class PlainText(
val content: String public val content: String
) : MessageContent { ) : MessageContent {
@PlannedRemoval("1.2.0") @PlannedRemoval("1.2.0")
...@@ -33,17 +33,17 @@ data class PlainText( ...@@ -33,17 +33,17 @@ data class PlainText(
level = DeprecationLevel.ERROR, level = DeprecationLevel.ERROR,
replaceWith = ReplaceWith("content") replaceWith = ReplaceWith("content")
) )
val stringValue: String public val stringValue: String
get() = content get() = content
@Suppress("unused") @Suppress("unused")
constructor(charSequence: CharSequence) : this(charSequence.toString()) public constructor(charSequence: CharSequence) : this(charSequence.toString())
override fun toString(): String = content public override fun toString(): String = content
override fun contentToString(): String = content public override fun contentToString(): String = content
companion object Key : Message.Key<PlainText> { public companion object Key : Message.Key<PlainText> {
override val typeName: String get() = "PlainText" public override val typeName: String get() = "PlainText"
} }
} }
...@@ -52,4 +52,4 @@ data class PlainText( ...@@ -52,4 +52,4 @@ data class PlainText(
*/ */
@JvmSynthetic @JvmSynthetic
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun String.toMessage(): PlainText = PlainText(this) public inline fun String.toMessage(): PlainText = PlainText(this)
\ No newline at end of file \ No newline at end of file
...@@ -7,4 +7,4 @@ import net.mamoe.mirai.Bot ...@@ -7,4 +7,4 @@ import net.mamoe.mirai.Bot
/** /**
* 当 [Bot] 被迫下线时抛出, 作为 [Job.cancel] 的 `cause` * 当 [Bot] 被迫下线时抛出, 作为 [Job.cancel] 的 `cause`
*/ */
class ForceOfflineException(override val message: String?) : CancellationException(message) public class ForceOfflineException(public override val message: String?) : CancellationException(message)
\ No newline at end of file \ No newline at end of file
...@@ -10,14 +10,16 @@ import net.mamoe.mirai.utils.MiraiInternalAPI ...@@ -10,14 +10,16 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
* **InternalAPI**: 这是内部 API, 它随时都有可能被修改 * **InternalAPI**: 这是内部 API, 它随时都有可能被修改
*/ */
@MiraiInternalAPI @MiraiInternalAPI
interface Packet { public interface Packet {
/** /**
* 实现这个接口的包将不会被记录到日志中 * 实现这个接口的包将不会被记录到日志中
*/ */
interface NoLog @MiraiInternalAPI
public interface NoLog
/** /**
* 实现这个接口的 [Event] 不会被作为事件记录到日志中 * 实现这个接口的 [Event] 不会被作为事件记录到日志中
*/ */
interface NoEventLog @MiraiInternalAPI
public interface NoEventLog
} }
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment