mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-27 17:00:14 +08:00
Rearrange protocol implementations
This commit is contained in:
parent
75f3f9de93
commit
1e7aaaec48
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("UnstableApiUsage", "UNUSED_VARIABLE")
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
@ -229,9 +238,9 @@ val experimentalAnnotations = arrayOf(
|
||||
"kotlin.RequiresOptIn",
|
||||
"kotlin.contracts.ExperimentalContracts",
|
||||
"kotlin.experimental.ExperimentalTypeInference",
|
||||
"net.mamoe.mirai.utils.MiraiInternalAPI",
|
||||
"net.mamoe.mirai.utils.MiraiExperimentalAPI",
|
||||
"net.mamoe.mirai.LowLevelAPI",
|
||||
"net.mamoe.mirai.utils.MiraiInternalApi",
|
||||
"net.mamoe.mirai.utils.MiraiExperimentalApi",
|
||||
"net.mamoe.mirai.LowLevelApi",
|
||||
"kotlinx.serialization.ExperimentalSerializationApi"
|
||||
)
|
||||
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "NOTHING_TO_INLINE", "RemoveRedundantBackticks")
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("ObjectPropertyName", "ObjectPropertyName", "unused")
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package upload
|
||||
|
||||
import org.gradle.api.Project
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
import java.security.MessageDigest
|
||||
|
@ -1,3 +1,11 @@
|
||||
#
|
||||
# Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
#
|
||||
# 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
# Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
#
|
||||
# https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
#
|
||||
# style guide
|
||||
kotlin.code.style=official
|
||||
# config
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
apply plugin: "com.android.library"
|
||||
|
||||
android {
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
apiValidation {
|
||||
ignoredPackages += [
|
||||
"net.mamoe.mirai.event.internal",
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
// 部分源码来自 kotlinx.coroutines
|
||||
// Source code from kotlinx.coroutines
|
||||
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
import upload.Bintray
|
||||
|
||||
// 部分源码来自 kotlinx.coroutines
|
||||
|
8
gradle/wrapper/gradle-wrapper.properties
vendored
8
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,3 +1,11 @@
|
||||
#
|
||||
# Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
#
|
||||
# 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
# Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
#
|
||||
# https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
#
|
||||
#Tue Mar 31 10:18:00 CST 2020
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
|
15
gradlew
vendored
15
gradlew
vendored
@ -1,19 +1,12 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
# Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("UnusedImport")
|
||||
|
||||
plugins {
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("UNUSED_VARIABLE")
|
||||
|
||||
plugins {
|
||||
|
@ -2,31 +2,25 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@file:Suppress(
|
||||
"EXPERIMENTAL_API_USAGE", "unused", "FunctionName", "NOTHING_TO_INLINE", "UnusedImport",
|
||||
"EXPERIMENTAL_OVERRIDE", "CanBeParameter", "MemberVisibilityCanBePrivate"
|
||||
"EXPERIMENTAL_OVERRIDE", "CanBeParameter", "MemberVisibilityCanBePrivate", "INAPPLICABLE_JVM_NAME",
|
||||
"EXPOSED_SUPER_CLASS"
|
||||
)
|
||||
|
||||
package net.mamoe.mirai
|
||||
|
||||
import kotlinx.coroutines.*
|
||||
import net.mamoe.mirai.contact.*
|
||||
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.MessageReceipt
|
||||
import net.mamoe.mirai.message.action.BotNudge
|
||||
import net.mamoe.mirai.message.action.MemberNudge
|
||||
import net.mamoe.mirai.message.action.Nudge
|
||||
import net.mamoe.mirai.message.data.*
|
||||
import net.mamoe.mirai.network.LoginFailedException
|
||||
import net.mamoe.mirai.utils.*
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
import kotlin.jvm.JvmField
|
||||
import kotlin.jvm.JvmStatic
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
@ -48,10 +42,9 @@ public suspend inline fun <B : Bot> B.alsoLogin(): B = also { login() }
|
||||
*
|
||||
* @see BotFactory 构造 [Bot] 的工厂, [Bot] 唯一的构造方式.
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME", "EXPOSED_SUPER_CLASS")
|
||||
public abstract class Bot internal constructor(
|
||||
public val configuration: BotConfiguration
|
||||
) : CoroutineScope, LowLevelBotAPIAccessor, BotJavaFriendlyAPI, ContactOrBot {
|
||||
) : CoroutineScope, ContactOrBot {
|
||||
public final override val coroutineContext: CoroutineContext = // for id
|
||||
configuration.parentCoroutineContext
|
||||
.plus(SupervisorJob(configuration.parentCoroutineContext[Job]))
|
||||
@ -124,7 +117,7 @@ public abstract class Bot internal constructor(
|
||||
* 在 JVM 的默认实现为 `class ContextImpl : Context`
|
||||
* 在 Android 实现为 `android.content.Context`
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public abstract val context: Context
|
||||
|
||||
/**
|
||||
@ -151,10 +144,10 @@ public abstract class Bot internal constructor(
|
||||
// region contacts
|
||||
|
||||
/**
|
||||
* [User.id] 与 [Bot.id] 相同的 [_lowLevelNewFriend] 实例
|
||||
* [User.id] 与 [Bot.id] 相同的 [Friend] 实例
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
public abstract val selfQQ: Friend
|
||||
@MiraiExperimentalApi
|
||||
public abstract val asFriend: Friend
|
||||
|
||||
|
||||
/**
|
||||
@ -183,8 +176,6 @@ public abstract class Bot internal constructor(
|
||||
|
||||
// endregion
|
||||
|
||||
// region network
|
||||
|
||||
/**
|
||||
* 登录, 或重新登录.
|
||||
* 这个函数总是关闭一切现有网路任务 (但不会关闭其他任务), 然后重新登录并重新缓存好友列表和群列表.
|
||||
@ -196,170 +187,16 @@ public abstract class Bot internal constructor(
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public abstract suspend fun login()
|
||||
// endregion
|
||||
|
||||
|
||||
// region actions
|
||||
|
||||
/**
|
||||
* 撤回这条消息. 可撤回自己 2 分钟内发出的消息, 和任意时间的群成员的消息.
|
||||
*
|
||||
* [Bot] 撤回自己的消息不需要权限.
|
||||
* [Bot] 撤回群员的消息需要管理员权限.
|
||||
*
|
||||
* @param source 消息源. 可从 [MessageReceipt.source] 获得, 或从消息事件中的 [MessageChain] 获得, 或通过 [buildMessageSource] 构建.
|
||||
*
|
||||
* @throws PermissionDeniedException 当 [Bot] 无权限操作时抛出
|
||||
* @throws IllegalStateException 当这条消息已经被撤回时抛出 (仅同步主动操作)
|
||||
*
|
||||
* @see Bot.recall (扩展函数) 接受参数 [MessageChain]
|
||||
* @see MessageSource.recall 撤回消息扩展
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public abstract suspend fun recall(source: MessageSource)
|
||||
|
||||
/**
|
||||
* 创建一个 "戳一戳" 消息
|
||||
*
|
||||
* @see MemberNudge.sendTo 发送这个戳一戳消息
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.3.0")
|
||||
public fun nudge(): BotNudge = BotNudge(this)
|
||||
|
||||
/**
|
||||
* 获取图片下载链接
|
||||
*
|
||||
* @see Image.queryUrl [Image] 的扩展函数
|
||||
*/
|
||||
@PlannedRemoval("1.2.0")
|
||||
@Deprecated(
|
||||
"use extension.",
|
||||
replaceWith = ReplaceWith("image.queryUrl()", imports = ["queryUrl"]),
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
@JvmSynthetic
|
||||
public abstract suspend fun queryImageUrl(image: Image): String
|
||||
|
||||
/**
|
||||
* 构造一个 [OfflineMessageSource]
|
||||
*
|
||||
* @param id 即 [MessageSource.id]
|
||||
* @param internalId 即 [MessageSource.internalId]
|
||||
*
|
||||
* @param fromUin 为用户时为 [Friend.id], 为群时需使用 [Group.calculateGroupUinByGroupCode] 计算
|
||||
* @param targetUin 为用户时为 [Friend.id], 为群时需使用 [Group.calculateGroupUinByGroupCode] 计算
|
||||
*/
|
||||
@MiraiExperimentalAPI("This is very experimental and is subject to change.")
|
||||
public abstract fun constructMessageSource(
|
||||
kind: OfflineMessageSource.Kind,
|
||||
fromUin: Long, targetUin: Long,
|
||||
id: Int, time: Int, internalId: Int,
|
||||
originalMessage: MessageChain
|
||||
): OfflineMessageSource
|
||||
|
||||
|
||||
/**
|
||||
* 通过好友验证
|
||||
*
|
||||
* @param event 好友验证的事件对象
|
||||
*/
|
||||
@PlannedRemoval("1.2.0")
|
||||
@Deprecated("use member function.", replaceWith = ReplaceWith("event.accept()"), level = DeprecationLevel.ERROR)
|
||||
@JvmSynthetic
|
||||
public abstract suspend fun acceptNewFriendRequest(event: NewFriendRequestEvent)
|
||||
|
||||
/**
|
||||
* 拒绝好友验证
|
||||
*
|
||||
* @param event 好友验证的事件对象
|
||||
* @param blackList 拒绝后是否拉入黑名单
|
||||
*/
|
||||
@PlannedRemoval("1.2.0")
|
||||
@Deprecated(
|
||||
"use member function.",
|
||||
replaceWith = ReplaceWith("event.reject(blackList)"),
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
@JvmSynthetic
|
||||
public abstract suspend fun rejectNewFriendRequest(event: NewFriendRequestEvent, blackList: Boolean = false)
|
||||
|
||||
/**
|
||||
* 通过加群验证(需管理员权限)
|
||||
*
|
||||
* @param event 加群验证的事件对象
|
||||
*/
|
||||
@PlannedRemoval("1.2.0")
|
||||
@Deprecated("use member function.", replaceWith = ReplaceWith("event.accept()"), level = DeprecationLevel.ERROR)
|
||||
@JvmSynthetic
|
||||
public abstract suspend fun acceptMemberJoinRequest(event: MemberJoinRequestEvent)
|
||||
|
||||
/**
|
||||
* 拒绝加群验证(需管理员权限)
|
||||
*
|
||||
* @param event 加群验证的事件对象
|
||||
* @param blackList 拒绝后是否拉入黑名单
|
||||
*/
|
||||
@PlannedRemoval("1.2.0")
|
||||
@Deprecated(
|
||||
"use member function.",
|
||||
replaceWith = ReplaceWith("event.reject(blackList)"),
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
public abstract suspend fun rejectMemberJoinRequest(event: MemberJoinRequestEvent, blackList: Boolean = false)
|
||||
|
||||
@JvmSynthetic
|
||||
public abstract suspend fun rejectMemberJoinRequest(
|
||||
event: MemberJoinRequestEvent,
|
||||
blackList: Boolean = false,
|
||||
message: String = ""
|
||||
)
|
||||
|
||||
/**
|
||||
* 忽略加群验证(需管理员权限)
|
||||
*
|
||||
* @param event 加群验证的事件对象
|
||||
* @param blackList 忽略后是否拉入黑名单
|
||||
*/
|
||||
@PlannedRemoval("1.2.0")
|
||||
@Deprecated(
|
||||
"use member function.",
|
||||
replaceWith = ReplaceWith("event.ignore(blackList)"),
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
@JvmSynthetic
|
||||
public abstract suspend fun ignoreMemberJoinRequest(event: MemberJoinRequestEvent, blackList: Boolean = false)
|
||||
|
||||
/**
|
||||
* 接收邀请入群(需管理员权限)
|
||||
*
|
||||
* @param event 邀请入群的事件对象
|
||||
*/
|
||||
@PlannedRemoval("1.2.0")
|
||||
@Deprecated("use member function.", replaceWith = ReplaceWith("event.accept()"), level = DeprecationLevel.ERROR)
|
||||
@JvmSynthetic
|
||||
public abstract suspend fun acceptInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent)
|
||||
|
||||
/**
|
||||
* 忽略邀请入群(需管理员权限)
|
||||
*
|
||||
* @param event 邀请入群的事件对象
|
||||
*/
|
||||
@PlannedRemoval("1.2.0")
|
||||
@Deprecated("use member function.", replaceWith = ReplaceWith("event.ignore()"), level = DeprecationLevel.ERROR)
|
||||
@JvmSynthetic
|
||||
public abstract suspend fun ignoreInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent)
|
||||
|
||||
@Deprecated(
|
||||
"use member function.",
|
||||
replaceWith = ReplaceWith("nudge.sendTo(contact)"),
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
@SinceMirai("1.3.0")
|
||||
public abstract suspend fun sendNudge(nudge: Nudge, receiver: Contact): Boolean
|
||||
|
||||
// endregion
|
||||
|
||||
/**
|
||||
* 关闭这个 [Bot], 立即取消 [Bot] 的 [SupervisorJob].
|
||||
* 之后 [isActive] 将会返回 `false`.
|
||||
@ -389,53 +226,6 @@ public val Bot.supervisorJob: CompletableJob
|
||||
@JvmSynthetic
|
||||
public suspend inline fun Bot.join(): Unit = this.coroutineContext[Job]!!.join()
|
||||
|
||||
/**
|
||||
* 撤回这条消息.
|
||||
*
|
||||
* [Bot] 撤回自己的消息不需要权限, 但需要在发出后 2 分钟内撤回.
|
||||
* [Bot] 撤回群员的消息需要管理员权限, 可在任意时间撤回.
|
||||
*
|
||||
* @throws PermissionDeniedException 当 [Bot] 无权限操作时
|
||||
* @see Bot.recall
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public suspend inline fun Bot.recall(message: MessageChain): Unit =
|
||||
this.recall(message.source)
|
||||
|
||||
/**
|
||||
* 在一段时间后撤回这个消息源所指代的消息.
|
||||
*
|
||||
* @param millis 延迟的时间, 单位为毫秒
|
||||
* @param coroutineContext 额外的 [CoroutineContext]
|
||||
* @see recall
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public inline fun CoroutineScope.recallIn(
|
||||
source: MessageSource,
|
||||
millis: Long,
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext
|
||||
): Job = this.launch(coroutineContext + CoroutineName("MessageRecall")) {
|
||||
delay(millis)
|
||||
source.recall()
|
||||
}
|
||||
|
||||
/**
|
||||
* 在一段时间后撤回这条消息.
|
||||
*
|
||||
* @param millis 延迟的时间, 单位为毫秒
|
||||
* @param coroutineContext 额外的 [CoroutineContext]
|
||||
* @see recall
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public inline fun CoroutineScope.recallIn(
|
||||
message: MessageChain,
|
||||
millis: Long,
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext
|
||||
): Job = this.launch(coroutineContext + CoroutineName("MessageRecall")) {
|
||||
delay(millis)
|
||||
message.recall()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭这个 [Bot], 停止一切相关活动. 所有引用都会被释放.
|
||||
*
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
163
mirai-core-api/src/commonMain/kotlin/Mirai.kt
Normal file
163
mirai-core-api/src/commonMain/kotlin/Mirai.kt
Normal file
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("INTERFACE_NOT_SUPPORTED")
|
||||
|
||||
package net.mamoe.mirai
|
||||
|
||||
import net.mamoe.kjbb.JvmBlockingBridge
|
||||
import net.mamoe.mirai.contact.Contact
|
||||
import net.mamoe.mirai.contact.Friend
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.contact.PermissionDeniedException
|
||||
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.MessageReceipt
|
||||
import net.mamoe.mirai.message.action.Nudge
|
||||
import net.mamoe.mirai.message.data.*
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
@OptIn(LowLevelApi::class, MiraiExperimentalApi::class)
|
||||
public interface Mirai : LowLevelApiAccessor {
|
||||
@Suppress("PropertyName")
|
||||
@MiraiExperimentalApi
|
||||
public val BotFactory: BotFactory
|
||||
|
||||
/**
|
||||
* 撤回这条消息. 可撤回自己 2 分钟内发出的消息, 和任意时间的群成员的消息.
|
||||
*
|
||||
* [Bot] 撤回自己的消息不需要权限.
|
||||
* [Bot] 撤回群员的消息需要管理员权限.
|
||||
*
|
||||
* @param source 消息源. 可从 [MessageReceipt.source] 获得, 或从消息事件中的 [MessageChain] 获得, 或通过 [buildMessageSource] 构建.
|
||||
*
|
||||
* @throws PermissionDeniedException 当 [Bot] 无权限操作时抛出
|
||||
* @throws IllegalStateException 当这条消息已经被撤回时抛出 (仅同步主动操作)
|
||||
*
|
||||
* @see Mirai.recall (扩展函数) 接受参数 [MessageChain]
|
||||
* @see MessageSource.recall 撤回消息扩展
|
||||
*/
|
||||
@JvmBlockingBridge
|
||||
public suspend fun recall(bot: Bot, source: MessageSource)
|
||||
|
||||
@JvmBlockingBridge
|
||||
public suspend fun sendNudge(bot: Bot, nudge: Nudge, receiver: Contact): Boolean
|
||||
|
||||
public fun createImage(imageId: String): Image
|
||||
|
||||
/**
|
||||
* 获取图片下载链接
|
||||
*
|
||||
* @see Image.queryUrl [Image] 的扩展函数
|
||||
*/
|
||||
@JvmBlockingBridge
|
||||
public suspend fun queryImageUrl(bot: Bot, image: Image): String
|
||||
|
||||
/**
|
||||
* 构造一个 [OfflineMessageSource]
|
||||
*
|
||||
* @param id 即 [MessageSource.id]
|
||||
* @param internalId 即 [MessageSource.internalId]
|
||||
*
|
||||
* @param fromUin 为用户时为 [Friend.id], 为群时需使用 [Group.calculateGroupUinByGroupCode] 计算
|
||||
* @param targetUin 为用户时为 [Friend.id], 为群时需使用 [Group.calculateGroupUinByGroupCode] 计算
|
||||
*/
|
||||
@MiraiExperimentalApi("This is very experimental and is subject to change.")
|
||||
public fun constructMessageSource(
|
||||
bot: Bot,
|
||||
kind: OfflineMessageSource.Kind,
|
||||
fromUin: Long, targetUin: Long,
|
||||
id: Int, time: Int, internalId: Int,
|
||||
originalMessage: MessageChain
|
||||
): OfflineMessageSource
|
||||
|
||||
|
||||
/**
|
||||
* 通过好友验证
|
||||
*
|
||||
* @param event 好友验证的事件对象
|
||||
*/
|
||||
@JvmBlockingBridge
|
||||
public suspend fun acceptNewFriendRequest(event: NewFriendRequestEvent)
|
||||
|
||||
/**
|
||||
* 拒绝好友验证
|
||||
*
|
||||
* @param event 好友验证的事件对象
|
||||
* @param blackList 拒绝后是否拉入黑名单
|
||||
*/
|
||||
@JvmBlockingBridge
|
||||
public suspend fun rejectNewFriendRequest(event: NewFriendRequestEvent, blackList: Boolean = false)
|
||||
|
||||
/**
|
||||
* 通过加群验证(需管理员权限)
|
||||
*
|
||||
* @param event 加群验证的事件对象
|
||||
*/
|
||||
@JvmBlockingBridge
|
||||
public suspend fun acceptMemberJoinRequest(event: MemberJoinRequestEvent)
|
||||
|
||||
/**
|
||||
* 拒绝加群验证(需管理员权限)
|
||||
*
|
||||
* @param event 加群验证的事件对象
|
||||
* @param blackList 拒绝后是否拉入黑名单
|
||||
*/
|
||||
@JvmBlockingBridge
|
||||
public suspend fun rejectMemberJoinRequest(
|
||||
event: MemberJoinRequestEvent,
|
||||
blackList: Boolean = false,
|
||||
message: String = ""
|
||||
)
|
||||
|
||||
/**
|
||||
* 忽略加群验证(需管理员权限)
|
||||
*
|
||||
* @param event 加群验证的事件对象
|
||||
* @param blackList 忽略后是否拉入黑名单
|
||||
*/
|
||||
@JvmBlockingBridge
|
||||
public suspend fun ignoreMemberJoinRequest(event: MemberJoinRequestEvent, blackList: Boolean = false)
|
||||
|
||||
/**
|
||||
* 接收邀请入群(需管理员权限)
|
||||
*
|
||||
* @param event 邀请入群的事件对象
|
||||
*/
|
||||
@JvmBlockingBridge
|
||||
public suspend fun acceptInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent)
|
||||
|
||||
/**
|
||||
* 忽略邀请入群(需管理员权限)
|
||||
*
|
||||
* @param event 邀请入群的事件对象
|
||||
*/
|
||||
@JvmBlockingBridge
|
||||
public suspend fun ignoreInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent)
|
||||
|
||||
|
||||
public companion object INSTANCE : Mirai by findMiraiInstance()
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回这条消息.
|
||||
*
|
||||
* [Bot] 撤回自己的消息不需要权限, 但需要在发出后 2 分钟内撤回.
|
||||
* [Bot] 撤回群员的消息需要管理员权限, 可在任意时间撤回.
|
||||
*
|
||||
* @throws PermissionDeniedException 当 [Bot] 无权限操作时
|
||||
* @see Mirai.recall
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public suspend inline fun Mirai.recall(bot: Bot, message: MessageChain): Unit =
|
||||
this.recall(bot, message.source)
|
||||
|
||||
internal expect fun findMiraiInstance(): Mirai
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -13,21 +13,18 @@
|
||||
package net.mamoe.mirai.contact
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.JavaFriendlyAPI
|
||||
import net.mamoe.mirai.Mirai
|
||||
import net.mamoe.mirai.event.events.*
|
||||
import net.mamoe.mirai.message.MessageReceipt
|
||||
import net.mamoe.mirai.message.data.*
|
||||
import net.mamoe.mirai.message.quote
|
||||
import net.mamoe.mirai.message.recall
|
||||
import net.mamoe.mirai.recall
|
||||
import net.mamoe.mirai.recallIn
|
||||
import net.mamoe.mirai.utils.ExternalImage
|
||||
import net.mamoe.mirai.utils.OverFileSizeMaxException
|
||||
import net.mamoe.mirai.utils.WeakRefProperty
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
|
||||
@ -35,7 +32,7 @@ import kotlin.jvm.JvmSynthetic
|
||||
* 联系对象, 即可以与 [Bot] 互动的对象. 包含 [用户][User], 和 [群][Group].
|
||||
*/
|
||||
@Suppress("EXPOSED_SUPER_CLASS")
|
||||
public abstract class Contact : ContactOrBot, CoroutineScope, ContactJavaFriendlyAPI {
|
||||
public abstract class Contact : ContactOrBot, CoroutineScope {
|
||||
/**
|
||||
* 这个联系对象所属 [Bot].
|
||||
*/
|
||||
@ -99,33 +96,13 @@ public abstract class Contact : ContactOrBot, CoroutineScope, ContactJavaFriendl
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Bot.recall
|
||||
* @see Mirai.recall
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public suspend inline fun Contact.recall(source: MessageChain): Unit = this.bot.recall(source)
|
||||
public suspend inline fun Contact.recall(source: MessageChain): Unit = Mirai.recall(bot, source)
|
||||
|
||||
/**
|
||||
* @see Bot.recall
|
||||
* @see Mirai.recall
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public suspend inline fun Contact.recall(source: MessageSource): Unit = this.bot.recall(source)
|
||||
|
||||
/**
|
||||
* @see Bot.recallIn
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public inline fun Contact.recallIn(
|
||||
message: MessageChain,
|
||||
millis: Long,
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext
|
||||
): Job = this.bot.recallIn(message, millis, coroutineContext)
|
||||
|
||||
/**
|
||||
* @see Bot.recallIn
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public inline fun Contact.recallIn(
|
||||
source: MessageSource,
|
||||
millis: Long,
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext
|
||||
): Job = this.bot.recallIn(source, millis, coroutineContext)
|
||||
public suspend inline fun Contact.recall(source: MessageSource): Unit = Mirai.recall(bot, source)
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -23,7 +23,7 @@ import net.mamoe.mirai.message.data.Message
|
||||
import net.mamoe.mirai.message.data.PlainText
|
||||
import net.mamoe.mirai.message.data.isContentEmpty
|
||||
import net.mamoe.mirai.message.recall
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
@ -82,7 +82,7 @@ public abstract class Friend : User(), CoroutineScope {
|
||||
*
|
||||
* @see FriendNudge.sendTo 发送这个戳一戳消息
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.3.0")
|
||||
public final override fun nudge(): FriendNudge = FriendNudge(this)
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -15,7 +15,7 @@ import kotlinx.coroutines.CoroutineScope
|
||||
import net.mamoe.kjbb.JvmBlockingBridge
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.JavaFriendlyAPI
|
||||
import net.mamoe.mirai.LowLevelAPI
|
||||
import net.mamoe.mirai.LowLevelApi
|
||||
import net.mamoe.mirai.data.MemberInfo
|
||||
import net.mamoe.mirai.event.events.*
|
||||
import net.mamoe.mirai.message.MessageReceipt
|
||||
@ -63,7 +63,7 @@ public abstract class Group : Contact(), CoroutineScope {
|
||||
/**
|
||||
* [Bot] 在群内的 [Member] 实例
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public abstract val botAsMember: Member
|
||||
|
||||
/**
|
||||
@ -127,8 +127,8 @@ public abstract class Group : Contact(), CoroutineScope {
|
||||
* 构造一个 [Member].
|
||||
* 非特殊情况请不要使用这个函数. 优先使用 [get].
|
||||
*/
|
||||
@LowLevelAPI
|
||||
@MiraiExperimentalAPI("dangerous")
|
||||
@LowLevelApi
|
||||
@MiraiExperimentalApi("dangerous")
|
||||
public abstract fun newMember(memberInfo: MemberInfo): Member
|
||||
|
||||
/**
|
||||
@ -184,7 +184,7 @@ public abstract class Group : Contact(), CoroutineScope {
|
||||
* @throws OverFileSizeMaxException 当语音文件过大而被服务器拒绝上传时. (最大大小约为 1 MB)
|
||||
*/
|
||||
@JvmBlockingBridge
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.2.0")
|
||||
public abstract suspend fun uploadVoice(input: InputStream): Voice
|
||||
|
||||
@ -194,7 +194,7 @@ public abstract class Group : Contact(), CoroutineScope {
|
||||
* 使用 groupCode 计算 groupUin. 这两个值仅在 mirai 内部协议区分, 一般人使用时无需在意.
|
||||
* @suppress internal api
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@JvmStatic
|
||||
public fun calculateGroupUinByGroupCode(groupCode: Long): Long =
|
||||
CommonGroupCalculations.calculateGroupUinByGroupCode(groupCode)
|
||||
@ -203,7 +203,7 @@ public abstract class Group : Contact(), CoroutineScope {
|
||||
* 使用 groupUin 计算 groupCode. 这两个值仅在 mirai 内部协议区分, 一般人使用时无需在意.
|
||||
* @suppress internal api
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@JvmStatic
|
||||
public fun calculateGroupCodeByGroupUin(groupUin: Long): Long =
|
||||
CommonGroupCalculations.calculateGroupCodeByGroupUin(groupUin)
|
||||
@ -269,7 +269,7 @@ public interface GroupSettings {
|
||||
/**
|
||||
* 自动加群审批
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public val isAutoApproveEnabled: Boolean
|
||||
|
||||
/**
|
||||
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.contact
|
||||
|
||||
import net.mamoe.mirai.JavaFriendlyAPI
|
||||
|
||||
/**
|
||||
* [Contact] 中为了让 `Java` 更容易调用的 API.
|
||||
* 不要用它作为一个类型, 只应使用其中的方法
|
||||
*/
|
||||
@JavaFriendlyAPI
|
||||
internal expect interface ContactJavaFriendlyAPI
|
||||
|
||||
/**
|
||||
* [Member] 中为了让 `Java` 更容易调用的 API
|
||||
* 不要用它作为一个类型, 只应使用其中的方法
|
||||
*/
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
@JavaFriendlyAPI
|
||||
internal expect interface MemberJavaFriendlyAPI
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -22,7 +22,7 @@ import net.mamoe.mirai.message.data.Message
|
||||
import net.mamoe.mirai.message.data.PlainText
|
||||
import net.mamoe.mirai.message.data.isContentEmpty
|
||||
import net.mamoe.mirai.message.recall
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
import net.mamoe.mirai.utils.WeakRefProperty
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
@ -40,7 +40,7 @@ import kotlin.time.ExperimentalTime
|
||||
*/
|
||||
@Suppress("INAPPLICABLE_JVM_NAME", "EXPOSED_SUPER_CLASS")
|
||||
@OptIn(JavaFriendlyAPI::class)
|
||||
public abstract class Member : MemberJavaFriendlyAPI, User() {
|
||||
public abstract class Member : User() {
|
||||
/**
|
||||
* 所在的群.
|
||||
*/
|
||||
@ -166,7 +166,7 @@ public abstract class Member : MemberJavaFriendlyAPI, User() {
|
||||
*
|
||||
* @see MemberNudge.sendTo 发送这个戳一戳消息
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.3.0")
|
||||
public final override fun nudge(): Nudge = MemberNudge(this)
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -23,7 +23,7 @@ import net.mamoe.mirai.message.data.PlainText
|
||||
import net.mamoe.mirai.message.data.isContentEmpty
|
||||
import net.mamoe.mirai.message.recall
|
||||
import net.mamoe.mirai.utils.ExternalImage
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.OverFileSizeMaxException
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
@ -89,7 +89,7 @@ public abstract class User : Contact(), CoroutineScope {
|
||||
*
|
||||
* @see FriendNudge.sendTo 发送这个戳一戳消息
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.3.0")
|
||||
public abstract fun nudge(): Nudge
|
||||
|
||||
|
@ -2,16 +2,16 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.data
|
||||
|
||||
import net.mamoe.mirai.LowLevelAPI
|
||||
import net.mamoe.mirai.LowLevelApi
|
||||
|
||||
@LowLevelAPI
|
||||
@LowLevelApi
|
||||
public interface FriendInfo {
|
||||
public val uin: Long
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -12,13 +12,13 @@ package net.mamoe.mirai.data
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
|
||||
|
||||
/**
|
||||
* 群统计信息
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@Serializable
|
||||
public data class GroupActiveData(
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -11,7 +11,7 @@ package net.mamoe.mirai.data
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
|
||||
/**
|
||||
* 群公告数据类
|
||||
@ -20,7 +20,7 @@ import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
* 发公告时只需要填写text,其他参数可为默认值
|
||||
*
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@Serializable
|
||||
public data class GroupAnnouncementList(
|
||||
val ec: Int, //状态码 0 是正常的
|
||||
@ -29,7 +29,7 @@ public data class GroupAnnouncementList(
|
||||
val inst: List<GroupAnnouncement>? = null //置顶列表?
|
||||
)
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@Serializable
|
||||
public data class GroupAnnouncement(
|
||||
@SerialName("u") val sender: Long = 0,
|
||||
@ -42,7 +42,7 @@ public data class GroupAnnouncement(
|
||||
val fid: String? = null //公告的id
|
||||
)
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@Serializable
|
||||
public data class GroupAnnouncementMsg(
|
||||
val text: String,
|
||||
@ -50,7 +50,7 @@ public data class GroupAnnouncementMsg(
|
||||
val title: String? = null
|
||||
)
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@Serializable
|
||||
public data class GroupAnnouncementSettings(
|
||||
@SerialName("is_show_edit_card") val isShowEditCard: Int = 0,
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.data
|
||||
|
||||
import kotlinx.serialization.KSerializer
|
||||
@ -9,14 +18,14 @@ import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
import kotlin.jvm.JvmStatic
|
||||
|
||||
/**
|
||||
* 群荣誉信息
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.3.0")
|
||||
public enum class GroupHonorType(public val value: Int) {
|
||||
TALKATIVE(1), // 龙王
|
||||
@ -27,13 +36,14 @@ public enum class GroupHonorType(public val value: Int) {
|
||||
ACTIVE(7), // 活跃头衔
|
||||
EXCLUSIVE(8), // 特殊头衔
|
||||
MANAGE(9); // 管理头衔
|
||||
|
||||
internal companion object {
|
||||
@JvmStatic
|
||||
internal fun deserializeFromInt(value: Int): GroupHonorType = values().first { it.value == value }
|
||||
}
|
||||
}
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.3.0")
|
||||
@Serializable
|
||||
public data class GroupHonorListData(
|
||||
|
@ -2,19 +2,19 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.data
|
||||
|
||||
import net.mamoe.mirai.LowLevelAPI
|
||||
import net.mamoe.mirai.LowLevelApi
|
||||
|
||||
/**
|
||||
* 群资料.
|
||||
*/
|
||||
@LowLevelAPI
|
||||
@LowLevelApi
|
||||
public interface GroupInfo {
|
||||
/**
|
||||
* Uin
|
||||
|
@ -2,17 +2,17 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.data
|
||||
|
||||
import net.mamoe.mirai.LowLevelAPI
|
||||
import net.mamoe.mirai.LowLevelApi
|
||||
import net.mamoe.mirai.contact.MemberPermission
|
||||
|
||||
@LowLevelAPI
|
||||
@LowLevelApi
|
||||
public interface MemberInfo : FriendInfo {
|
||||
public val nameCard: String
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -16,7 +16,7 @@ import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import net.mamoe.mirai.JavaFriendlyAPI
|
||||
import net.mamoe.mirai.event.internal.broadcastInternal
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
import net.mamoe.mirai.utils.internal.runBlocking
|
||||
import kotlin.jvm.JvmField
|
||||
@ -180,7 +180,7 @@ public fun <E : Event> E.__broadcastJava(): E = apply {
|
||||
* 设置为 `true` 以关闭事件.
|
||||
* 所有的 `subscribe` 都能正常添加到监听器列表, 但所有的广播都会直接返回.
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public var EventDisabled: Boolean = false
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -17,10 +17,9 @@ import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.contact.*
|
||||
import net.mamoe.mirai.event.AbstractEvent
|
||||
import net.mamoe.mirai.internal.network.Packet
|
||||
import net.mamoe.mirai.message.action.Nudge
|
||||
import net.mamoe.mirai.message.MessageEvent
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.MiraiInternalApi
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
@ -61,7 +60,7 @@ public sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
|
||||
* 被服务器断开
|
||||
*/
|
||||
@SinceMirai("1.1.0")
|
||||
@MiraiInternalAPI("This is very experimental and might be changed")
|
||||
@MiraiInternalApi("This is very experimental and might be changed")
|
||||
public data class MsfOffline internal constructor(
|
||||
public override val bot: Bot,
|
||||
public override val cause: Throwable?
|
||||
@ -78,7 +77,7 @@ public sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
|
||||
/**
|
||||
* 因 returnCode = -10008 等原因掉线
|
||||
*/
|
||||
@MiraiInternalAPI("This is very experimental and might be changed")
|
||||
@MiraiInternalApi("This is very experimental and might be changed")
|
||||
@SinceMirai("1.2.0")
|
||||
public data class PacketFactory10008 internal constructor(
|
||||
public override val bot: Bot,
|
||||
@ -88,13 +87,13 @@ public sealed class BotOfflineEvent : BotEvent, AbstractEvent() {
|
||||
/**
|
||||
* 服务器主动要求更换另一个服务器
|
||||
*/
|
||||
@MiraiInternalAPI
|
||||
@MiraiInternalApi
|
||||
public data class RequireReconnect internal constructor(
|
||||
public override val bot: Bot
|
||||
) : BotOfflineEvent(), Packet,
|
||||
BotPassiveEvent
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public interface CauseAware {
|
||||
public val cause: Throwable?
|
||||
}
|
||||
@ -128,11 +127,11 @@ public data class BotNickChangedEvent(
|
||||
) : BotEvent, Packet, AbstractEvent()
|
||||
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.3.0")
|
||||
public sealed class BotNudgedEvent : AbstractEvent(), BotEvent, Packet {
|
||||
/**
|
||||
* 戳一戳的发起人,为 [Bot] 的某一好友, 或某一群员, 或 [Bot.selfQQ]
|
||||
* 戳一戳的发起人,为 [Bot] 的某一好友, 或某一群员, 或 [Bot.asFriend]
|
||||
*/
|
||||
public abstract val from: User
|
||||
|
||||
@ -142,7 +141,7 @@ public sealed class BotNudgedEvent : AbstractEvent(), BotEvent, Packet {
|
||||
/** 戳一戳中设置的自定义后缀 */
|
||||
public abstract val suffix: String
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("2.0.0")
|
||||
/** [Bot] 在群聊中被戳 */
|
||||
public sealed class InGroup : BotNudgedEvent(), GroupMemberEvent {
|
||||
@ -178,7 +177,7 @@ public sealed class BotNudgedEvent : AbstractEvent(), BotEvent, Packet {
|
||||
}
|
||||
}
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("2.0.0")
|
||||
/** [Bot] 在私聊中被戳 */
|
||||
public sealed class InPrivateSession : BotNudgedEvent(), FriendEvent {
|
||||
@ -205,7 +204,7 @@ public sealed class BotNudgedEvent : AbstractEvent(), BotEvent, Packet {
|
||||
override val action: String,
|
||||
override val suffix: String
|
||||
) : InPrivateSession() {
|
||||
override val from: Friend get() = bot.selfQQ
|
||||
override val from: Friend get() = bot.asFriend
|
||||
override fun toString(): String {
|
||||
return "BotNudgedEvent.InPrivateSession.ByBot(friend=$friend, action=$action, suffix=$suffix)"
|
||||
}
|
||||
@ -246,7 +245,7 @@ public data class BotNudgedEvent internal constructor(
|
||||
*
|
||||
* @see MessageEvent.subject
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("2.0.0")
|
||||
public val BotNudgedEvent.subject: Contact
|
||||
get() = when (val inlineFrom = from) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -15,6 +15,7 @@ package net.mamoe.mirai.event.events
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.JavaFriendlyAPI
|
||||
import net.mamoe.mirai.Mirai
|
||||
import net.mamoe.mirai.contact.Friend
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.contact.User
|
||||
@ -22,7 +23,7 @@ import net.mamoe.mirai.event.AbstractEvent
|
||||
import net.mamoe.mirai.event.internal.MiraiAtomicBoolean
|
||||
import net.mamoe.mirai.internal.network.Packet
|
||||
import net.mamoe.mirai.message.action.Nudge
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
import net.mamoe.mirai.utils.internal.runBlocking
|
||||
import kotlin.jvm.*
|
||||
@ -97,10 +98,10 @@ public data class NewFriendRequestEvent internal constructor(
|
||||
public val fromGroup: Group? = if (fromGroupId == 0L) null else bot.getGroup(fromGroupId)
|
||||
|
||||
@JvmSynthetic
|
||||
public suspend fun accept(): Unit = bot.acceptNewFriendRequest(this)
|
||||
public suspend fun accept(): Unit = Mirai.acceptNewFriendRequest(this)
|
||||
|
||||
@JvmSynthetic
|
||||
public suspend fun reject(blackList: Boolean = false): Unit = bot.rejectNewFriendRequest(this, blackList)
|
||||
public suspend fun reject(blackList: Boolean = false): Unit = Mirai.rejectNewFriendRequest(this, blackList)
|
||||
|
||||
|
||||
@JavaFriendlyAPI
|
||||
@ -149,10 +150,10 @@ public data class FriendInputStatusChangedEvent internal constructor(
|
||||
* 注: 此事件仅可能在私聊中发生
|
||||
*/
|
||||
@SinceMirai("2.0.0")
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public sealed class FriendNudgedEvent : AbstractEvent(), FriendEvent, Packet {
|
||||
/**
|
||||
* 戳一戳的发起人, 为 [Bot] 的某一好友, 或是 [Bot.selfQQ]
|
||||
* 戳一戳的发起人, 为 [Bot] 的某一好友, 或是 [Bot.asFriend]
|
||||
*/
|
||||
public abstract val from: Friend
|
||||
|
||||
@ -167,7 +168,7 @@ public sealed class FriendNudgedEvent : AbstractEvent(), FriendEvent, Packet {
|
||||
public abstract val suffix: String
|
||||
|
||||
/** 在 [Bot] 与 [Friend] 的对话中 [Friend] 戳了自己事件 */
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public data class NudgedByHimself internal constructor(
|
||||
override val action: String,
|
||||
override val suffix: String,
|
||||
@ -182,7 +183,7 @@ public sealed class FriendNudgedEvent : AbstractEvent(), FriendEvent, Packet {
|
||||
}
|
||||
|
||||
/** [Bot] 戳了 [Friend] */
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public data class NudgedByBot internal constructor(
|
||||
override val action: String,
|
||||
override val suffix: String,
|
||||
@ -193,6 +194,6 @@ public sealed class FriendNudgedEvent : AbstractEvent(), FriendEvent, Packet {
|
||||
}
|
||||
|
||||
override val from: Friend
|
||||
get() = bot.selfQQ
|
||||
get() = bot.asFriend
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -15,6 +15,7 @@ package net.mamoe.mirai.event.events
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.JavaFriendlyAPI
|
||||
import net.mamoe.mirai.Mirai
|
||||
import net.mamoe.mirai.contact.Friend
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.contact.Member
|
||||
@ -24,7 +25,7 @@ import net.mamoe.mirai.event.BroadcastControllable
|
||||
import net.mamoe.mirai.event.internal.MiraiAtomicBoolean
|
||||
import net.mamoe.mirai.internal.network.Packet
|
||||
import net.mamoe.mirai.message.action.Nudge
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
import net.mamoe.mirai.utils.internal.runBlocking
|
||||
import kotlin.internal.LowPriorityInOverloadResolution
|
||||
@ -39,7 +40,7 @@ public sealed class BotLeaveEvent : BotEvent, Packet, AbstractEvent() {
|
||||
/**
|
||||
* 机器人主动退出一个群.
|
||||
*/
|
||||
@MiraiExperimentalAPI("目前此事件类型不一定正确. 部分被踢出情况也会广播此事件.")
|
||||
@MiraiExperimentalApi("目前此事件类型不一定正确. 部分被踢出情况也会广播此事件.")
|
||||
public data class Active internal constructor(
|
||||
public override val group: Group
|
||||
) : BotLeaveEvent() {
|
||||
@ -49,7 +50,7 @@ public sealed class BotLeaveEvent : BotEvent, Packet, AbstractEvent() {
|
||||
/**
|
||||
* 机器人被管理员或群主踢出群.
|
||||
*/
|
||||
@MiraiExperimentalAPI("BotLeaveEvent 的子类可能在将来改动. 使用 BotLeaveEvent 以保证兼容性.")
|
||||
@MiraiExperimentalApi("BotLeaveEvent 的子类可能在将来改动. 使用 BotLeaveEvent 以保证兼容性.")
|
||||
public data class Kick internal constructor(
|
||||
public override val operator: Member
|
||||
) : BotLeaveEvent(),
|
||||
@ -107,7 +108,7 @@ public sealed class BotJoinGroupEvent : GroupEvent, BotPassiveEvent, Packet, Abs
|
||||
/**
|
||||
* 不确定. 可能是主动加入
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public data class Active internal constructor(
|
||||
public override val group: Group
|
||||
) : BotJoinGroupEvent() {
|
||||
@ -119,7 +120,7 @@ public sealed class BotJoinGroupEvent : GroupEvent, BotPassiveEvent, Packet, Abs
|
||||
*
|
||||
* 此时服务器基于 Bot 的 QQ 设置自动同意了请求.
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public data class Invite internal constructor(
|
||||
/**
|
||||
* 邀请人
|
||||
@ -137,7 +138,7 @@ public sealed class BotJoinGroupEvent : GroupEvent, BotPassiveEvent, Packet, Abs
|
||||
* 原群主通过 https://huifu.qq.com/ 恢复原来群主身份并入群,
|
||||
* [Bot] 是原群主
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.3.0")
|
||||
public data class Retrieve internal constructor(
|
||||
public override val group: Group
|
||||
@ -341,20 +342,20 @@ public data class BotInvitedJoinGroupRequestEvent internal constructor(
|
||||
internal val responded: MiraiAtomicBoolean = MiraiAtomicBoolean(false)
|
||||
|
||||
@JvmSynthetic
|
||||
public suspend fun accept(): Unit = bot.acceptInvitedJoinGroupRequest(this)
|
||||
public suspend fun accept(): Unit = Mirai.acceptInvitedJoinGroupRequest(this)
|
||||
|
||||
@JvmSynthetic
|
||||
public suspend fun ignore(): Unit = bot.ignoreInvitedJoinGroupRequest(this)
|
||||
public suspend fun ignore(): Unit = Mirai.ignoreInvitedJoinGroupRequest(this)
|
||||
|
||||
@JavaFriendlyAPI
|
||||
@JvmName("accept")
|
||||
public fun __acceptBlockingForJava__(): Unit =
|
||||
runBlocking { bot.acceptInvitedJoinGroupRequest(this@BotInvitedJoinGroupRequestEvent) }
|
||||
runBlocking { Mirai.acceptInvitedJoinGroupRequest(this@BotInvitedJoinGroupRequestEvent) }
|
||||
|
||||
@JavaFriendlyAPI
|
||||
@JvmName("ignore")
|
||||
public fun __ignoreBlockingForJava__(): Unit =
|
||||
runBlocking { bot.ignoreInvitedJoinGroupRequest(this@BotInvitedJoinGroupRequestEvent) }
|
||||
runBlocking { Mirai.ignoreInvitedJoinGroupRequest(this@BotInvitedJoinGroupRequestEvent) }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -385,36 +386,37 @@ public data class MemberJoinRequestEvent internal constructor(
|
||||
public val group: Group get() = this.bot.getGroup(groupId)
|
||||
|
||||
@JvmField
|
||||
@PublishedApi
|
||||
internal val responded: MiraiAtomicBoolean = MiraiAtomicBoolean(false)
|
||||
|
||||
@JvmSynthetic
|
||||
public suspend fun accept(): Unit = bot.acceptMemberJoinRequest(this)
|
||||
public suspend fun accept(): Unit = Mirai.acceptMemberJoinRequest(this)
|
||||
|
||||
@JvmSynthetic
|
||||
@JvmOverloads
|
||||
public suspend fun reject(blackList: Boolean = false, message: String = ""): Unit =
|
||||
bot.rejectMemberJoinRequest(this, blackList, message)
|
||||
Mirai.rejectMemberJoinRequest(this, blackList, message)
|
||||
|
||||
@JvmSynthetic
|
||||
public suspend fun ignore(blackList: Boolean = false): Unit = bot.ignoreMemberJoinRequest(this, blackList)
|
||||
public suspend fun ignore(blackList: Boolean = false): Unit = Mirai.ignoreMemberJoinRequest(this, blackList)
|
||||
|
||||
|
||||
@JavaFriendlyAPI
|
||||
@JvmName("accept")
|
||||
public fun __acceptBlockingForJava__(): Unit =
|
||||
runBlocking { bot.acceptMemberJoinRequest(this@MemberJoinRequestEvent) }
|
||||
runBlocking { Mirai.acceptMemberJoinRequest(this@MemberJoinRequestEvent) }
|
||||
|
||||
@JavaFriendlyAPI
|
||||
@JvmOverloads
|
||||
@JvmName("reject")
|
||||
public fun __rejectBlockingForJava__(blackList: Boolean = false, message: String = ""): Unit =
|
||||
runBlocking { bot.rejectMemberJoinRequest(this@MemberJoinRequestEvent, blackList, message) }
|
||||
runBlocking { Mirai.rejectMemberJoinRequest(this@MemberJoinRequestEvent, blackList, message) }
|
||||
|
||||
@JavaFriendlyAPI
|
||||
@JvmOverloads
|
||||
@JvmName("ignore")
|
||||
public fun __ignoreBlockingForJava__(blackList: Boolean = false): Unit =
|
||||
runBlocking { bot.ignoreMemberJoinRequest(this@MemberJoinRequestEvent, blackList) }
|
||||
runBlocking { Mirai.ignoreMemberJoinRequest(this@MemberJoinRequestEvent, blackList) }
|
||||
}
|
||||
|
||||
// endregion
|
||||
@ -518,7 +520,7 @@ public data class MemberUnmuteEvent internal constructor(
|
||||
/**
|
||||
* [Member] 被 [戳][Nudge] 的事件.
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.3.0")
|
||||
public data class MemberNudgedEvent internal constructor(
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -314,7 +314,7 @@ public sealed class MessageRecallEvent : BotEvent, AbstractEvent() {
|
||||
/**
|
||||
* 群消息撤回事件.
|
||||
*/
|
||||
public data class GroupRecall internal constructor(
|
||||
public data class GroupRecall @PublishedApi internal constructor(
|
||||
public override val bot: Bot,
|
||||
public override val authorId: Long,
|
||||
public override val messageId: Int,
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -116,6 +116,7 @@ internal expect object GlobalEventListeners {
|
||||
operator fun get(priority: Listener.EventPriority): LockFreeLinkedList<ListenerRegistry>
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
internal expect class MiraiAtomicBoolean(initial: Boolean) {
|
||||
|
||||
fun compareAndSet(expect: Boolean, update: Boolean): Boolean
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -17,7 +17,7 @@ import net.mamoe.mirai.message.data.Message
|
||||
import net.mamoe.mirai.message.data.PlainText
|
||||
import net.mamoe.mirai.message.isContextIdenticalWith
|
||||
import net.mamoe.mirai.message.nextMessage
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
@ -68,7 +68,7 @@ public suspend inline fun <reified T : MessageEvent> T.whileSelectMessages(
|
||||
/**
|
||||
* [selectMessages] 的 [Unit] 返回值捷径 (由于 Kotlin 无法推断 [Unit] 类型)
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@JvmName("selectMessages1")
|
||||
public suspend inline fun <reified T : MessageEvent> T.selectMessagesUnit(
|
||||
timeoutMillis: Long = -1,
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -10,7 +10,7 @@
|
||||
package net.mamoe.mirai.internal.network
|
||||
|
||||
import net.mamoe.mirai.event.Event
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalApi
|
||||
|
||||
/**
|
||||
* 从服务器收到的包解析之后的结构化数据.
|
||||
@ -18,17 +18,17 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
*
|
||||
* **InternalAPI**: 这是内部 API, 它随时都有可能被修改
|
||||
*/
|
||||
@MiraiInternalAPI
|
||||
@MiraiInternalApi
|
||||
public interface Packet {
|
||||
/**
|
||||
* 实现这个接口的包将不会被记录到日志中
|
||||
*/
|
||||
@MiraiInternalAPI
|
||||
@MiraiInternalApi
|
||||
public interface NoLog
|
||||
|
||||
/**
|
||||
* 实现这个接口的 [Event] 不会被作为事件记录到日志中
|
||||
*/
|
||||
@MiraiInternalAPI
|
||||
@MiraiInternalApi
|
||||
public interface NoEventLog
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -16,16 +16,3 @@ package net.mamoe.mirai
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
|
||||
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.TYPE, AnnotationTarget.CLASS)
|
||||
internal annotation class JavaFriendlyAPI
|
||||
|
||||
/**
|
||||
* [Bot] 中为了让 Java 使用者调用更方便的 API 列表.
|
||||
*
|
||||
* **注意**: 不应该把这个类作为一个类型, 只应使用其中的方法
|
||||
*/
|
||||
@Suppress("FunctionName", "INAPPLICABLE_JVM_NAME", "unused")
|
||||
internal expect interface BotJavaFriendlyAPI
|
||||
|
||||
// 保留多平台结构, 以避免在 Android 和 JVM 都定义这个类
|
||||
// 待 https://youtrack.jetbrains.com/issue/KT-27801 实现后修改为 hierarchical MPP 架构
|
||||
|
||||
// 待 https://youtrack.jetbrains.com/issue/KT-36740 修复后添加 Future 相关 API 到 hierarchical MPP 架构中
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -13,7 +13,7 @@ import kotlinx.coroutines.Job
|
||||
import net.mamoe.mirai.contact.Friend
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.data.*
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
import net.mamoe.mirai.utils.WeakRef
|
||||
|
||||
@ -24,10 +24,11 @@ import net.mamoe.mirai.utils.WeakRef
|
||||
* 使用低级的 API 无法带来任何安全和便捷保障.
|
||||
* 仅在某些使用结构化 API 可能影响性能的情况下使用这些低级 API.
|
||||
*/
|
||||
@MiraiExperimentalApi
|
||||
@RequiresOptIn
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
|
||||
public annotation class LowLevelAPI
|
||||
public annotation class LowLevelApi
|
||||
|
||||
/**
|
||||
* [Bot] 相关协议层低级 API.
|
||||
@ -36,24 +37,24 @@ public annotation class LowLevelAPI
|
||||
*
|
||||
* **警告**: 所有的低级 API 都可能在任意时刻不经过任何警告和迭代就被修改. 因此非常不建议在任何情况下使用这些 API.
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@Suppress("FunctionName", "unused")
|
||||
@LowLevelAPI
|
||||
public interface LowLevelBotAPIAccessor {
|
||||
@LowLevelApi
|
||||
public interface LowLevelApiAccessor {
|
||||
/**
|
||||
* 构造一个 [Friend] 对象. 它持有对 [Bot] 的弱引用([WeakRef]).
|
||||
*
|
||||
* [Bot] 无法管理这个对象, 但这个对象会以 [Bot] 的 [Job] 作为父 Job.
|
||||
* 因此, 当 [Bot] 被关闭后, 这个对象也会被关闭.
|
||||
*/
|
||||
@LowLevelAPI
|
||||
public fun _lowLevelNewFriend(friendInfo: FriendInfo): Friend
|
||||
@LowLevelApi
|
||||
public fun _lowLevelNewFriend(bot: Bot, friendInfo: FriendInfo): Friend
|
||||
|
||||
/**
|
||||
* 向服务器查询群列表. 返回值高 32 bits 为 uin, 低 32 bits 为 groupCode
|
||||
*/
|
||||
@LowLevelAPI
|
||||
public suspend fun _lowLevelQueryGroupList(): Sequence<Long>
|
||||
@LowLevelApi
|
||||
public suspend fun _lowLevelQueryGroupList(bot: Bot): Sequence<Long>
|
||||
|
||||
/**
|
||||
* 向服务器查询群成员列表.
|
||||
@ -63,8 +64,9 @@ public interface LowLevelBotAPIAccessor {
|
||||
*
|
||||
* @see Group.calculateGroupUinByGroupCode 使用 groupCode 计算 groupUin
|
||||
*/
|
||||
@LowLevelAPI
|
||||
@LowLevelApi
|
||||
public suspend fun _lowLevelQueryGroupMemberList(
|
||||
bot: Bot,
|
||||
groupUin: Long,
|
||||
groupCode: Long,
|
||||
ownerId: Long
|
||||
@ -74,35 +76,47 @@ public interface LowLevelBotAPIAccessor {
|
||||
* 获取群公告列表
|
||||
* @param page 页码
|
||||
*/
|
||||
@LowLevelAPI
|
||||
@MiraiExperimentalAPI
|
||||
public suspend fun _lowLevelGetAnnouncements(groupId: Long, page: Int = 1, amount: Int = 10): GroupAnnouncementList
|
||||
@LowLevelApi
|
||||
@MiraiExperimentalApi
|
||||
public suspend fun _lowLevelGetAnnouncements(
|
||||
bot: Bot,
|
||||
groupId: Long, page: Int = 1, amount: Int = 10
|
||||
): GroupAnnouncementList
|
||||
|
||||
/**
|
||||
* 发送群公告
|
||||
*
|
||||
* @return 公告的fid
|
||||
*/
|
||||
@LowLevelAPI
|
||||
@MiraiExperimentalAPI
|
||||
public suspend fun _lowLevelSendAnnouncement(groupId: Long, announcement: GroupAnnouncement): String
|
||||
@LowLevelApi
|
||||
@MiraiExperimentalApi
|
||||
public suspend fun _lowLevelSendAnnouncement(
|
||||
bot: Bot,
|
||||
groupId: Long, announcement: GroupAnnouncement
|
||||
): String
|
||||
|
||||
|
||||
/**
|
||||
* 删除群公告
|
||||
* @param fid [GroupAnnouncement.fid]
|
||||
*/
|
||||
@LowLevelAPI
|
||||
@MiraiExperimentalAPI
|
||||
public suspend fun _lowLevelDeleteAnnouncement(groupId: Long, fid: String)
|
||||
@LowLevelApi
|
||||
@MiraiExperimentalApi
|
||||
public suspend fun _lowLevelDeleteAnnouncement(
|
||||
bot: Bot,
|
||||
groupId: Long, fid: String
|
||||
)
|
||||
|
||||
/**
|
||||
* 获取一条群公告
|
||||
* @param fid [GroupAnnouncement.fid]
|
||||
*/
|
||||
@LowLevelAPI
|
||||
@MiraiExperimentalAPI
|
||||
public suspend fun _lowLevelGetAnnouncement(groupId: Long, fid: String): GroupAnnouncement
|
||||
@LowLevelApi
|
||||
@MiraiExperimentalApi
|
||||
public suspend fun _lowLevelGetAnnouncement(
|
||||
bot: Bot,
|
||||
groupId: Long, fid: String
|
||||
): GroupAnnouncement
|
||||
|
||||
|
||||
/**
|
||||
@ -110,25 +124,30 @@ public interface LowLevelBotAPIAccessor {
|
||||
* 不传page可得到趋势图
|
||||
* page从0开始传入可以得到发言列表
|
||||
*/
|
||||
@LowLevelAPI
|
||||
@MiraiExperimentalAPI
|
||||
public suspend fun _lowLevelGetGroupActiveData(groupId: Long, page: Int = -1): GroupActiveData
|
||||
@LowLevelApi
|
||||
@MiraiExperimentalApi
|
||||
public suspend fun _lowLevelGetGroupActiveData(bot: Bot, groupId: Long, page: Int = -1): GroupActiveData
|
||||
|
||||
|
||||
/**
|
||||
* 获取群荣誉信息
|
||||
*/
|
||||
@SinceMirai("1.3.0")
|
||||
@LowLevelAPI
|
||||
@MiraiExperimentalAPI
|
||||
public suspend fun _lowLevelGetGroupHonorListData(groupId: Long, type: GroupHonorType): GroupHonorListData?
|
||||
@LowLevelApi
|
||||
@MiraiExperimentalApi
|
||||
public suspend fun _lowLevelGetGroupHonorListData(
|
||||
bot: Bot,
|
||||
groupId: Long,
|
||||
type: GroupHonorType
|
||||
): GroupHonorListData?
|
||||
|
||||
|
||||
/**
|
||||
* 处理一个账号请求添加机器人为好友的事件
|
||||
*/
|
||||
@LowLevelAPI
|
||||
@LowLevelApi
|
||||
public suspend fun _lowLevelSolveNewFriendRequestEvent(
|
||||
bot: Bot,
|
||||
eventId: Long,
|
||||
fromId: Long,
|
||||
fromNick: String,
|
||||
@ -139,8 +158,9 @@ public interface LowLevelBotAPIAccessor {
|
||||
/**
|
||||
* 处理被邀请加入一个群请求事件
|
||||
*/
|
||||
@LowLevelAPI
|
||||
@LowLevelApi
|
||||
public suspend fun _lowLevelSolveBotInvitedJoinGroupRequestEvent(
|
||||
bot: Bot,
|
||||
eventId: Long,
|
||||
invitorId: Long,
|
||||
groupId: Long,
|
||||
@ -150,9 +170,10 @@ public interface LowLevelBotAPIAccessor {
|
||||
/**
|
||||
* 处理账号请求加入群事件
|
||||
*/
|
||||
@LowLevelAPI
|
||||
@LowLevelApi
|
||||
@SinceMirai("1.2.0")
|
||||
public suspend fun _lowLevelSolveMemberJoinRequestEvent(
|
||||
bot: Bot,
|
||||
eventId: Long,
|
||||
fromId: Long,
|
||||
fromNick: String,
|
||||
@ -165,9 +186,10 @@ public interface LowLevelBotAPIAccessor {
|
||||
/**
|
||||
* 查询语音的下载连接
|
||||
*/
|
||||
@LowLevelAPI
|
||||
@LowLevelApi
|
||||
@SinceMirai("1.2.0")
|
||||
public suspend fun _lowLevelQueryGroupVoiceDownloadUrl(
|
||||
bot: Bot,
|
||||
md5: ByteArray,
|
||||
groupId: Long,
|
||||
dstUin: Long
|
||||
@ -176,9 +198,10 @@ public interface LowLevelBotAPIAccessor {
|
||||
/**
|
||||
* 查询语音的上传连接
|
||||
*/
|
||||
@LowLevelAPI
|
||||
@LowLevelApi
|
||||
@SinceMirai("1.2.0")
|
||||
public suspend fun _lowLevelUploadVoice(
|
||||
bot: Bot,
|
||||
md5: ByteArray,
|
||||
groupId: Long,
|
||||
)
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -11,17 +11,10 @@
|
||||
|
||||
package net.mamoe.mirai.message
|
||||
|
||||
import kotlinx.coroutines.Job
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.JavaFriendlyAPI
|
||||
import net.mamoe.mirai.Mirai
|
||||
import net.mamoe.mirai.contact.*
|
||||
import net.mamoe.mirai.message.data.*
|
||||
import net.mamoe.mirai.recallIn
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.internal.runBlocking
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
import kotlin.jvm.JvmName
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
/**
|
||||
@ -41,7 +34,7 @@ import kotlin.jvm.JvmSynthetic
|
||||
* @see MessageReceipt.sourceId 源 id
|
||||
* @see MessageReceipt.sourceTime 源时间
|
||||
*/
|
||||
public 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(
|
||||
/**
|
||||
* 指代发送出去的消息.
|
||||
*/
|
||||
@ -54,94 +47,25 @@ public open class MessageReceipt<out C : Contact> @MiraiExperimentalAPI("The con
|
||||
/**
|
||||
* @see Group.botAsMember
|
||||
*/
|
||||
@MiraiExperimentalAPI("This is subject to change.")
|
||||
@MiraiExperimentalApi("This is subject to change.")
|
||||
public val botAsMember: Member?
|
||||
) {
|
||||
/**
|
||||
* 是否为发送给群的消息的回执
|
||||
*/
|
||||
public val isToGroup: Boolean get() = target is Group
|
||||
|
||||
/**
|
||||
* 引用这条消息并回复.
|
||||
*
|
||||
* 仅供 Java 使用.
|
||||
*
|
||||
* 仅供 Java 使用: `MessageReceipt.quoteReply(message)`
|
||||
*/
|
||||
@JavaFriendlyAPI
|
||||
@JvmName("quoteReply")
|
||||
public fun __quoteReplyBlockingForJava__(message: Message): MessageReceipt<C> {
|
||||
return runBlocking { return@runBlocking quoteReply(message) }
|
||||
}
|
||||
|
||||
/**
|
||||
* 引用这条消息并回复.
|
||||
*
|
||||
* 仅供 Java 使用: `MessageReceipt.quoteReply(message)`
|
||||
*/
|
||||
@JavaFriendlyAPI
|
||||
@JvmName("quoteReply")
|
||||
public fun __quoteReplyBlockingForJava__(message: String): MessageReceipt<C> {
|
||||
return runBlocking { quoteReply(message) }
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回这条消息. [recall] 或 [recallIn] 只能被调用一次.
|
||||
*
|
||||
* 仅供 Java 使用: `MessageReceipt.recall()`
|
||||
*/
|
||||
@JavaFriendlyAPI
|
||||
@JvmName("recall")
|
||||
public fun __recallBlockingForJava__() {
|
||||
return runBlocking { recall() }
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回这条消息. [recall] 或 [recallIn] 只能被调用一次.
|
||||
*
|
||||
* 仅供 Java 使用: `MessageReceipt.recallIn(timeMillis)`
|
||||
*/
|
||||
@JavaFriendlyAPI
|
||||
@JvmName("recallIn")
|
||||
public fun __recallInBlockingForJava__(timeMillis: Long): Job {
|
||||
return recallIn(timeMillis = timeMillis)
|
||||
}
|
||||
|
||||
/**
|
||||
* 引用这条消息.
|
||||
*
|
||||
* 仅供 Java 使用: `MessageReceipt.quote()`
|
||||
*/
|
||||
@JavaFriendlyAPI
|
||||
@JvmName("quote")
|
||||
public fun __quoteBlockingForJava__(): QuoteReply {
|
||||
return this.quote()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回这条消息. [recall] 或 [recallIn] 只能被调用一次.
|
||||
*
|
||||
* @see Bot.recall
|
||||
* @see Mirai.recall
|
||||
* @throws IllegalStateException 当此消息已经被撤回或正计划撤回时
|
||||
*/
|
||||
public suspend inline fun MessageReceipt<*>.recall() {
|
||||
return target.bot.recall(source)
|
||||
return Mirai.recall(target.bot, source)
|
||||
}
|
||||
|
||||
/**
|
||||
* 在一段时间后撤回这条消息. [recall] 或 [recallIn] 只能被调用一次.
|
||||
*
|
||||
* @param timeMillis 延迟时间, 单位为毫秒
|
||||
* @throws IllegalStateException 当此消息已经被撤回或正计划撤回时
|
||||
*/
|
||||
public inline fun MessageReceipt<*>.recallIn(
|
||||
timeMillis: Long,
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext
|
||||
): Job = source.recallIn(timeMillis, coroutineContext)
|
||||
|
||||
|
||||
/**
|
||||
* 引用这条消息.
|
||||
* @see MessageChain.quote 引用一条消息
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -10,12 +10,13 @@ package net.mamoe.mirai.message.action
|
||||
|
||||
import net.mamoe.kjbb.JvmBlockingBridge
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.Mirai
|
||||
import net.mamoe.mirai.contact.*
|
||||
import net.mamoe.mirai.event.events.BotNudgedEvent
|
||||
import net.mamoe.mirai.event.events.MemberNudgedEvent
|
||||
import net.mamoe.mirai.utils.BotConfiguration
|
||||
import net.mamoe.mirai.utils.BotConfiguration.MiraiProtocol
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
|
||||
/**
|
||||
@ -26,7 +27,7 @@ import net.mamoe.mirai.utils.SinceMirai
|
||||
* @see User.nudge 创建 [Nudge] 对象
|
||||
* @see Bot.nudge 创建 [Nudge] 对象
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.3.0")
|
||||
public sealed class Nudge {
|
||||
/**
|
||||
@ -49,10 +50,10 @@ public sealed class Nudge {
|
||||
* @return 成功发送时为 `true`. 若对方禁用 "戳一戳" 功能, 返回 `false`.
|
||||
*/
|
||||
@JvmBlockingBridge
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public suspend fun sendTo(receiver: Contact): Boolean {
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
return receiver.bot.sendNudge(this, receiver)
|
||||
return Mirai.sendNudge(receiver.bot, this, receiver)
|
||||
}
|
||||
|
||||
public companion object {
|
||||
@ -68,7 +69,7 @@ public sealed class Nudge {
|
||||
*
|
||||
* @return 成功发送时为 `true`. 若对方禁用 "戳一戳" 功能, 返回 `false`.
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@JvmBlockingBridge
|
||||
public suspend fun Contact.sendNudge(nudge: Nudge): Boolean = nudge.sendTo(this)
|
||||
}
|
||||
@ -78,7 +79,7 @@ public sealed class Nudge {
|
||||
* @see Bot.nudge
|
||||
* @see Nudge
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.3.0")
|
||||
public data class BotNudge(
|
||||
public override val target: Bot
|
||||
@ -88,7 +89,7 @@ public data class BotNudge(
|
||||
* @see User.nudge
|
||||
* @see Nudge
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.3.0")
|
||||
public sealed class UserNudge : Nudge() {
|
||||
public abstract override val target: User
|
||||
@ -98,7 +99,7 @@ public sealed class UserNudge : Nudge() {
|
||||
* @see Member.nudge
|
||||
* @see Nudge
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.3.0")
|
||||
public data class MemberNudge(
|
||||
public override val target: Member
|
||||
@ -108,7 +109,7 @@ public data class MemberNudge(
|
||||
* @see Friend.nudge
|
||||
* @see Nudge
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.3.0")
|
||||
public data class FriendNudge(
|
||||
public override val target: Friend
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.LowLevelAPI
|
||||
import net.mamoe.mirai.LowLevelApi
|
||||
import net.mamoe.mirai.contact.Member
|
||||
import net.mamoe.mirai.contact.nameCardOrNick
|
||||
import net.mamoe.mirai.message.code.CodableMessage
|
||||
@ -63,7 +63,7 @@ private constructor(
|
||||
*/
|
||||
@Suppress("FunctionName")
|
||||
@JvmStatic
|
||||
@LowLevelAPI
|
||||
@LowLevelApi
|
||||
public fun _lowLevelConstructAtInstance(target: Long, display: String): At = At(target, display)
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,12 +2,12 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:OptIn(MiraiInternalAPI::class)
|
||||
@file:OptIn(MiraiInternalApi::class)
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
@ -34,7 +34,7 @@ import kotlin.jvm.JvmOverloads
|
||||
*
|
||||
* @see CustomMessageMetadata 自定义消息元数据
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public sealed class CustomMessage : SingleMessage {
|
||||
/**
|
||||
* 获取这个消息的工厂
|
||||
@ -48,7 +48,7 @@ public sealed class CustomMessage : SingleMessage {
|
||||
* @see JsonSerializerFactory 使用 [Json] 作为序列模式的 [Factory]
|
||||
* @see ProtoBufSerializerFactory 使用 [ProtoBuf] 作为序列模式的 [Factory]
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public abstract class Factory<M : CustomMessage>(
|
||||
/**
|
||||
* 此类型消息的名称.
|
||||
@ -172,7 +172,7 @@ public sealed class CustomMessage : SingleMessage {
|
||||
/**
|
||||
* 序列化这个消息
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@SinceMirai("1.1.0")
|
||||
public fun <T : CustomMessage> T.toByteArray(): ByteArray {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@ -190,7 +190,7 @@ public fun <T : CustomMessage> T.toByteArray(): ByteArray {
|
||||
* @see CustomMessage 查看更多信息
|
||||
* @see ConstrainSingle 可实现此接口以保证消息链中只存在一个元素
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public abstract class CustomMessageMetadata : CustomMessage(), MessageMetadata {
|
||||
public companion object Key : Message.Key<CustomMessageMetadata> {
|
||||
override val typeName: String get() = "CustomMessageMetadata"
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -18,7 +18,7 @@ import net.mamoe.mirai.contact.User
|
||||
import net.mamoe.mirai.contact.nameCardOrNick
|
||||
import net.mamoe.mirai.message.MessageEvent
|
||||
import net.mamoe.mirai.message.data.ForwardMessage.DisplayStrategy
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.currentTimeSeconds
|
||||
import kotlin.jvm.JvmOverloads
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
@ -182,7 +182,7 @@ public class ForwardMessage @JvmOverloads constructor(
|
||||
public override fun toString(): String = "[mirai:forward:$nodeList]"
|
||||
private val contentToString: String by lazy { nodeList.joinToString("\n") }
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public override fun contentToString(): String = contentToString
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -17,15 +17,17 @@
|
||||
"DEPRECATION",
|
||||
"UnusedImport",
|
||||
"EXPOSED_SUPER_CLASS",
|
||||
"DEPRECATION_ERROR"
|
||||
"DEPRECATION_ERROR", "NOTHING_TO_INLINE"
|
||||
)
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.Mirai
|
||||
import net.mamoe.mirai.contact.Contact
|
||||
import net.mamoe.mirai.message.code.CodableMessage
|
||||
import net.mamoe.mirai.utils.ExternalImage
|
||||
import net.mamoe.mirai.utils.MiraiInternalApi
|
||||
import net.mamoe.mirai.utils.sendImage
|
||||
import kotlin.js.JsName
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
@ -51,7 +53,7 @@ import kotlin.jvm.JvmSynthetic
|
||||
*
|
||||
* ### 下载图片
|
||||
* @see Image.queryUrl 扩展函数. 查询图片下载链接
|
||||
* @see Bot.queryImageUrl 查询图片下载链接 (Java 使用)
|
||||
* @see Mirai.queryImageUrl 查询图片下载链接 (Java 使用)
|
||||
*
|
||||
* 查看平台 `actual` 定义以获取上传方式扩展.
|
||||
*
|
||||
@ -89,15 +91,20 @@ public expect interface Image : Message, MessageContent, CodableMessage {
|
||||
|
||||
final override fun contentToString(): String = "[图片]"
|
||||
*/
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
"""
|
||||
不要自行实现 Image, 它必须由协议模块实现, 否则会无法发送也无法解析.
|
||||
""", level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
@Suppress("PropertyName")
|
||||
@get:JvmSynthetic
|
||||
internal val DoNotImplementThisClass: Nothing?
|
||||
/**
|
||||
* 所有 [Image] 实现的基类.
|
||||
*/
|
||||
public abstract class AbstractImage : Image { // make sealed in 1.3.0 ?
|
||||
private var _stringValue: String? = null
|
||||
get() = field ?: kotlin.run {
|
||||
field = "[mirai:image:$imageId]"
|
||||
field
|
||||
}
|
||||
|
||||
final override fun toString(): String = _stringValue!!
|
||||
final override fun contentToString(): String = "[图片]"
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,7 +123,8 @@ public val Image.md5: ByteArray
|
||||
* [imageId] 形如 `/f8f1ab55-bf8e-4236-b55e-955848d7069f` (37 长度) 或 `/000000000-3814297509-BFB7027B9354B8F899A062061D74E206` (54 长度)
|
||||
*/
|
||||
// NotOnlineImage
|
||||
public abstract class FriendImage internal constructor() : AbstractImage() { // change to sealed in the future.
|
||||
public abstract class FriendImage @MiraiInternalApi public constructor() :
|
||||
AbstractImage() { // change to sealed in the future.
|
||||
public companion object Key : Message.Key<FriendImage> {
|
||||
public override val typeName: String get() = "FriendImage"
|
||||
}
|
||||
@ -129,7 +137,8 @@ public abstract class FriendImage internal constructor() : AbstractImage() { //
|
||||
* @see Image 查看更多说明
|
||||
*/
|
||||
// CustomFace
|
||||
public abstract class GroupImage internal constructor() : AbstractImage() { // change to sealed in the future.
|
||||
public abstract class GroupImage @MiraiInternalApi public constructor() :
|
||||
AbstractImage() { // change to sealed in the future.
|
||||
public companion object Key : Message.Key<GroupImage> {
|
||||
public override val typeName: String get() = "GroupImage"
|
||||
}
|
||||
@ -176,12 +185,7 @@ public val GROUP_IMAGE_ID_REGEX: Regex = Regex("""\{[0-9a-fA-F]{8}-([0-9a-fA-F]{
|
||||
@Suppress("FunctionName", "DEPRECATION")
|
||||
@JsName("newImage")
|
||||
@JvmName("newImage")
|
||||
public fun Image(imageId: String): OfflineImage = when {
|
||||
imageId matches FRIEND_IMAGE_ID_REGEX_1 -> OfflineFriendImage(imageId)
|
||||
imageId matches FRIEND_IMAGE_ID_REGEX_2 -> OfflineFriendImage(imageId)
|
||||
imageId matches GROUP_IMAGE_ID_REGEX -> OfflineGroupImage(imageId)
|
||||
else -> throw IllegalArgumentException("Illegal imageId: $imageId. $ILLEGAL_IMAGE_ID_EXCEPTION_MESSAGE")
|
||||
}
|
||||
public inline fun Image(imageId: String): Image = Mirai.createImage(imageId)
|
||||
|
||||
/**
|
||||
* 查询原图下载链接.
|
||||
@ -195,11 +199,7 @@ public fun Image(imageId: String): OfflineImage = when {
|
||||
//@JvmBlockingBridge
|
||||
@JvmSynthetic
|
||||
public suspend fun Image.queryUrl(): String {
|
||||
@Suppress("DEPRECATION")
|
||||
return when (this) {
|
||||
is ConstOriginUrlAware -> this.originUrl
|
||||
is DeferredOriginUrlAware -> this.getUrl(firstOnlineBotInstance)
|
||||
is SuspendDeferredOriginUrlAware -> this.getUrl(firstOnlineBotInstance)
|
||||
else -> error("Internal error: unsupported Image class: ${this::class}")
|
||||
}
|
||||
val bot = Bot._instances.peekFirst()?.get() ?: error("No Bot available to query image url")
|
||||
return Mirai.queryImageUrl(bot, this)
|
||||
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -23,7 +23,7 @@ import net.mamoe.mirai.contact.Contact
|
||||
import net.mamoe.mirai.message.MessageEvent
|
||||
import net.mamoe.mirai.message.MessageReceipt
|
||||
import net.mamoe.mirai.message.data.Message.Key
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import kotlin.contracts.contract
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
@ -204,7 +204,7 @@ public interface Message { // must be interface. Don't consider any changes.
|
||||
another.fold(this, Message::plus).asMessageChain()
|
||||
}
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@JvmSynthetic
|
||||
public suspend inline operator fun Message.plus(another: Flow<Message>): MessageChain =
|
||||
another.fold(this) { acc, it -> acc + it }.asMessageChain()
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -13,17 +13,14 @@
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import kotlinx.coroutines.Job
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.Mirai
|
||||
import net.mamoe.mirai.contact.*
|
||||
import net.mamoe.mirai.message.MessageEvent
|
||||
import net.mamoe.mirai.message.MessageReceipt
|
||||
import net.mamoe.mirai.message.quote
|
||||
import net.mamoe.mirai.message.recall
|
||||
import net.mamoe.mirai.recallIn
|
||||
import net.mamoe.mirai.utils.LazyProperty
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
@ -361,27 +358,10 @@ public inline fun MessageChain.quote(): QuoteReply = QuoteReply(this.source)
|
||||
* @throws PermissionDeniedException 当 [Bot] 无权限操作时
|
||||
* @throws IllegalStateException 当这条消息已经被撤回时 (仅同步主动操作)
|
||||
*
|
||||
* @see Bot.recall
|
||||
* @see Mirai.recall
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public suspend inline fun MessageSource.recall(): Unit = bot.recall(this)
|
||||
|
||||
/**
|
||||
* 在一段时间后撤回这条消息. 可撤回自己 2 分钟内发出的消息, 和任意时间的群成员的消息.
|
||||
*
|
||||
* [Bot] 撤回自己的消息不需要权限.
|
||||
* [Bot] 撤回群员的消息需要管理员权限.
|
||||
*
|
||||
* @throws PermissionDeniedException 当 [Bot] 无权限操作时
|
||||
* @throws IllegalStateException 当这条消息已经被撤回时 (仅同步主动操作)
|
||||
*
|
||||
* @see Bot.recall
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public inline fun MessageSource.recallIn(
|
||||
timeMillis: Long,
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext
|
||||
): Job = bot.recallIn(this, timeMillis, coroutineContext)
|
||||
public suspend inline fun MessageSource.recall(): Unit = Mirai.recall(bot, this)
|
||||
|
||||
// For MessageChain
|
||||
|
||||
@ -451,28 +431,7 @@ public val MessageChain.source: MessageSource
|
||||
* @throws PermissionDeniedException 当 [Bot] 无权限操作时
|
||||
* @throws IllegalStateException 当这条消息已经被撤回时 (仅同步主动操作)
|
||||
*
|
||||
* @see Bot.recall
|
||||
* @see Mirai.recall
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public suspend inline fun MessageChain.recall(): Unit = this.source.recall()
|
||||
|
||||
/**
|
||||
* 在一段时间后撤回这条消息. 可撤回自己 2 分钟内发出的消息, 和任意时间的群成员的消息.
|
||||
*
|
||||
* **注意:** 仅从服务器接收的消息 (即来自 [MessageEvent.message]), 或手动添加了 [MessageSource] 元素的 [MessageChain] 才可以撤回.
|
||||
*
|
||||
* *提示: 若要撤回一条机器人自己发出的消息, 使用 [Contact.sendMessage] 返回的 [MessageReceipt] 中的 [MessageReceipt.recall]*
|
||||
*
|
||||
* [Bot] 撤回自己的消息不需要权限.
|
||||
* [Bot] 撤回群员的消息需要管理员权限.
|
||||
*
|
||||
* @throws PermissionDeniedException 当 [Bot] 无权限操作时
|
||||
* @throws IllegalStateException 当这条消息已经被撤回时 (仅同步主动操作)
|
||||
*
|
||||
* @see Bot.recall
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public inline fun MessageChain.recallIn(
|
||||
millis: Long,
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext
|
||||
): Job = source.recallIn(millis, coroutineContext)
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -14,11 +14,12 @@
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.Mirai
|
||||
import net.mamoe.mirai.contact.ContactOrBot
|
||||
import net.mamoe.mirai.contact.Friend
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.contact.Member
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.currentTimeSeconds
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
@ -41,7 +42,7 @@ public fun OnlineMessageSource.toOffline(): OfflineMessageSource =
|
||||
*
|
||||
* @see buildMessageSource 查看更多说明
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@JvmName("copySource")
|
||||
public fun MessageSource.copyAmend(
|
||||
block: MessageSourceAmender.() -> Unit
|
||||
@ -103,10 +104,11 @@ public interface MessageSourceAmender {
|
||||
* ```
|
||||
*/
|
||||
@JvmSynthetic
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public fun Bot.buildMessageSource(block: MessageSourceBuilder.() -> Unit): MessageSource {
|
||||
val builder = MessageSourceBuilderImpl().apply(block)
|
||||
return constructMessageSource(
|
||||
return Mirai.constructMessageSource(
|
||||
this,
|
||||
builder.kind ?: error("You must call `Contact.sendTo(Contact)` when `buildMessageSource`"),
|
||||
builder.fromUin,
|
||||
builder.targetUin,
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -13,14 +13,9 @@
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import kotlinx.coroutines.Job
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmOverloads
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
|
||||
@ -69,64 +64,3 @@ public inline val QuoteReply.bot: Bot
|
||||
*/
|
||||
@JvmSynthetic
|
||||
public suspend inline fun QuoteReply.recallSource(): Unit = this.source.recall()
|
||||
|
||||
/**
|
||||
* 在一段时间后撤回引用的源消息
|
||||
*/
|
||||
@JvmOverloads
|
||||
public inline fun QuoteReply.recallSourceIn(
|
||||
millis: Long,
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext
|
||||
): Job = this.source.recallIn(millis, coroutineContext)
|
||||
|
||||
|
||||
//// 因语义不明而弃用的 API, 兼容到 1.3.0
|
||||
|
||||
@PlannedRemoval("1.3.0")
|
||||
@get:JvmSynthetic
|
||||
@Deprecated("use source.id for clearer semantics", ReplaceWith("source.id"))
|
||||
public inline val QuoteReply.id: Int
|
||||
get() = source.id
|
||||
|
||||
@PlannedRemoval("1.3.0")
|
||||
@get:JvmSynthetic
|
||||
@Deprecated("use source.internalId for clearer semantics", ReplaceWith("source.internalId"))
|
||||
public inline val QuoteReply.internalId: Int
|
||||
get() = source.internalId
|
||||
|
||||
@PlannedRemoval("1.3.0")
|
||||
@get:JvmSynthetic
|
||||
@Deprecated("use source.fromId for clearer semantics", ReplaceWith("source.fromId"))
|
||||
public inline val QuoteReply.fromId: Long
|
||||
get() = source.fromId
|
||||
|
||||
@PlannedRemoval("1.3.0")
|
||||
@get:JvmSynthetic
|
||||
@Deprecated("use source.targetId for clearer semantics", ReplaceWith("source.targetId"))
|
||||
public inline val QuoteReply.targetId: Long
|
||||
get() = source.targetId
|
||||
|
||||
@PlannedRemoval("1.3.0")
|
||||
@get:JvmSynthetic
|
||||
@Deprecated("use source.originalMessage for clearer semantics", ReplaceWith("source.originalMessage"))
|
||||
public inline val QuoteReply.originalMessage: MessageChain
|
||||
get() = source.originalMessage
|
||||
|
||||
@PlannedRemoval("1.3.0")
|
||||
@get:JvmSynthetic
|
||||
@Deprecated("use source.time for clearer semantics", ReplaceWith("source.time"))
|
||||
public inline val QuoteReply.time: Int
|
||||
get() = source.time
|
||||
|
||||
@PlannedRemoval("1.3.0")
|
||||
@Deprecated("use recallSourceIn for clearer semantics", ReplaceWith("recallSourceIn(millis, coroutineContext)"))
|
||||
@JvmOverloads
|
||||
public inline fun QuoteReply.recallIn(
|
||||
millis: Long,
|
||||
coroutineContext: CoroutineContext = EmptyCoroutineContext
|
||||
): Job = recallSourceIn(millis, coroutineContext)
|
||||
|
||||
@PlannedRemoval("1.3.0")
|
||||
@Deprecated("use recallSource for clearer semantics", ReplaceWith("this.recallSource()"))
|
||||
@JvmSynthetic
|
||||
public suspend inline fun QuoteReply.recall(): Unit = recallSource()
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import kotlin.annotation.AnnotationTarget.*
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
@ -34,7 +34,7 @@ public interface RichMessage : MessageContent {
|
||||
/**
|
||||
* **注意**: 富文本消息的 [RichMessage.contentEquals] 和 [RichMessage.toString] 都不稳定. 将来可能在没有任何警告的情况下改变格式.
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public override fun contentToString(): String = this.content
|
||||
|
||||
/**
|
||||
@ -46,13 +46,13 @@ public interface RichMessage : MessageContent {
|
||||
* 一些模板
|
||||
* @suppress 此 API 不稳定, 可能在任意时刻被删除
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public companion object Templates : Message.Key<RichMessage> {
|
||||
|
||||
/**
|
||||
* @suppress 此 API 不稳定, 可能在任意时刻被删除
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public fun share(
|
||||
url: String,
|
||||
title: String? = null,
|
||||
@ -150,11 +150,11 @@ commonElem=CommonElem#750141174 {
|
||||
*/
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
@JvmSynthetic
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public inline fun buildXmlMessage(serviceId: Int, block: @XmlMessageDsl XmlMessageBuilder.() -> Unit): ServiceMessage =
|
||||
ServiceMessage(serviceId, XmlMessageBuilder().apply(block).text)
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@Target(CLASS, FUNCTION, TYPE)
|
||||
@DslMarker
|
||||
public annotation class XmlMessageDsl
|
||||
@ -162,7 +162,7 @@ public annotation class XmlMessageDsl
|
||||
/**
|
||||
* @suppress 此 API 不稳定
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@XmlMessageDsl
|
||||
public class XmlMessageBuilder(
|
||||
public var templateId: Int = 1,
|
||||
@ -225,7 +225,7 @@ public class XmlMessageBuilder(
|
||||
}
|
||||
}
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
internal class LongMessage internal constructor(content: String, val resId: String) : ServiceMessage(35, content) {
|
||||
companion object Key : Message.Key<LongMessage> {
|
||||
override val typeName: String get() = "LongMessage"
|
||||
|
@ -2,21 +2,21 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.MiraiInternalApi
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
|
||||
/**
|
||||
* 需要通过上传到服务器的消息,如语音、文件
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public abstract class PttMessage : MessageContent {
|
||||
|
||||
public companion object Key : Message.Key<PttMessage> {
|
||||
@ -34,7 +34,7 @@ public abstract class PttMessage : MessageContent {
|
||||
* 语音消息, 目前只支持接收和转发
|
||||
*/
|
||||
@SinceMirai("1.2.0")
|
||||
public class Voice @MiraiInternalAPI constructor(
|
||||
public class Voice @MiraiInternalApi constructor(
|
||||
public override val fileName: String,
|
||||
public override val md5: ByteArray,
|
||||
public override val fileSize: Long,
|
||||
|
@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:JvmMultifileClass
|
||||
@file:JvmName("MessageUtils")
|
||||
|
||||
@file:Suppress(
|
||||
"EXPERIMENTAL_API_USAGE",
|
||||
"unused",
|
||||
"DEPRECATION",
|
||||
"UnusedImport",
|
||||
"EXPOSED_SUPER_CLASS",
|
||||
"DEPRECATION_ERROR"
|
||||
)
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.contact.Contact
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.utils.PlannedRemoval
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
|
||||
/////////////////////////
|
||||
///// 以下 API 已弃用 /////
|
||||
/////////////////////////
|
||||
|
||||
|
||||
// region 已启用
|
||||
|
||||
internal const val ONLINE_OFFLINE_DEPRECATION_MESSAGE = """
|
||||
自 1.0.0 起, mirai 已经能正常处理离线图片和在线图片的下载链接等功能.
|
||||
使用者无需考虑一个图片为在线图片还是离线图片, 只需使用 Image 类型.
|
||||
"""
|
||||
|
||||
|
||||
@PlannedRemoval("1.2.0") // 改为 internal
|
||||
@Deprecated(
|
||||
ONLINE_OFFLINE_DEPRECATION_MESSAGE,
|
||||
level = DeprecationLevel.ERROR,
|
||||
replaceWith = ReplaceWith("Image", "Image")
|
||||
)
|
||||
@Suppress("EXPOSED_SUPER_INTERFACE")
|
||||
public interface OnlineImage : Image, ConstOriginUrlAware {
|
||||
public companion object Key : Message.Key<OnlineImage> {
|
||||
public override val typeName: String get() = "OnlineImage"
|
||||
}
|
||||
|
||||
public override val originUrl: String
|
||||
}
|
||||
|
||||
/**
|
||||
* 离线的图片, 即为客户端主动上传到服务器而获得的 [Image] 实例.
|
||||
* 不能直接获取它在服务器上的链接. 需要通过 [Bot.queryImageUrl] 查询
|
||||
*
|
||||
* 一般由 [Contact.uploadImage] 得到
|
||||
*/
|
||||
@PlannedRemoval("1.2.0") // 改为 internal
|
||||
@Deprecated(
|
||||
ONLINE_OFFLINE_DEPRECATION_MESSAGE,
|
||||
level = DeprecationLevel.ERROR,
|
||||
replaceWith = ReplaceWith("Image", "Image")
|
||||
)
|
||||
public interface OfflineImage : Image {
|
||||
public companion object Key : Message.Key<OfflineImage> {
|
||||
public override val typeName: String get() = "OfflineImage"
|
||||
}
|
||||
}
|
||||
|
||||
@PlannedRemoval("1.2.0") // 删除
|
||||
@Deprecated(
|
||||
ONLINE_OFFLINE_DEPRECATION_MESSAGE,
|
||||
level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
@JvmSynthetic
|
||||
public suspend fun OfflineImage.queryUrl(): String {
|
||||
return Bot._instances.peekFirst()?.get()?.queryImageUrl(this) ?: error("No Bot available to query image url")
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 [Group.uploadImage] 上传得到的 [GroupImage]. 它的链接需要查询 [Bot.queryImageUrl]
|
||||
*
|
||||
* @param imageId 参考 [Image.imageId]
|
||||
*/
|
||||
@PlannedRemoval("1.2.0") // 改为 internal
|
||||
@Deprecated(
|
||||
ONLINE_OFFLINE_DEPRECATION_MESSAGE,
|
||||
level = DeprecationLevel.ERROR,
|
||||
replaceWith = ReplaceWith("Image", "Image")
|
||||
)
|
||||
@Serializable
|
||||
public data class OfflineGroupImage(
|
||||
public override val imageId: String
|
||||
) : GroupImage(), OfflineImage, DeferredOriginUrlAware {
|
||||
public override fun getUrl(bot: Bot): String {
|
||||
return "http://gchat.qpic.cn/gchatpic_new/${bot.id}/0-0-${
|
||||
imageId.substring(1..36)
|
||||
.replace("-", "")
|
||||
}/0?term=2"
|
||||
}
|
||||
|
||||
init {
|
||||
@Suppress("DEPRECATION")
|
||||
require(imageId matches GROUP_IMAGE_ID_REGEX) {
|
||||
"Illegal imageId. It must matches GROUP_IMAGE_ID_REGEX"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收消息时获取到的 [GroupImage]. 它可以直接获取下载链接 [originUrl]
|
||||
*/
|
||||
@PlannedRemoval("1.2.0") // 改为 internal
|
||||
@Deprecated(
|
||||
ONLINE_OFFLINE_DEPRECATION_MESSAGE,
|
||||
level = DeprecationLevel.ERROR,
|
||||
replaceWith = ReplaceWith("Image", "Image")
|
||||
)
|
||||
public abstract class OnlineGroupImage : GroupImage(), OnlineImage
|
||||
|
||||
/**
|
||||
* 通过 [Group.uploadImage] 上传得到的 [GroupImage]. 它的链接需要查询 [Bot.queryImageUrl]
|
||||
*
|
||||
* @param imageId 参考 [Image.imageId]
|
||||
*/
|
||||
@PlannedRemoval("1.2.0") // 改为 internal
|
||||
@Deprecated(
|
||||
ONLINE_OFFLINE_DEPRECATION_MESSAGE,
|
||||
level = DeprecationLevel.ERROR,
|
||||
replaceWith = ReplaceWith("Image", "Image")
|
||||
)
|
||||
@Serializable
|
||||
public data class OfflineFriendImage(
|
||||
public override val imageId: String
|
||||
) : FriendImage(), OfflineImage, DeferredOriginUrlAware {
|
||||
public override fun getUrl(bot: Bot): String {
|
||||
return "http://c2cpicdw.qpic.cn/offpic_new/${bot.id}/${this.imageId}/0?term=2"
|
||||
}
|
||||
|
||||
init {
|
||||
require(imageId matches FRIEND_IMAGE_ID_REGEX_1 || imageId matches FRIEND_IMAGE_ID_REGEX_2) {
|
||||
"Illegal imageId. It must matches either FRIEND_IMAGE_ID_REGEX_1 or FRIEND_IMAGE_ID_REGEX_2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收消息时获取到的 [FriendImage]. 它可以直接获取下载链接 [originUrl]
|
||||
*/
|
||||
@PlannedRemoval("1.2.0") // 改为 internal
|
||||
@Deprecated(
|
||||
ONLINE_OFFLINE_DEPRECATION_MESSAGE,
|
||||
level = DeprecationLevel.ERROR,
|
||||
replaceWith = ReplaceWith("Image", "Image")
|
||||
)
|
||||
public abstract class OnlineFriendImage : FriendImage(), OnlineImage
|
||||
|
||||
// endregion
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -13,10 +13,7 @@
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.utils.ExternalImage
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
@ -24,62 +21,6 @@ import kotlin.native.concurrent.SharedImmutable
|
||||
|
||||
// region image
|
||||
|
||||
/**
|
||||
* 所有 [Image] 实现的基类.
|
||||
*/
|
||||
internal abstract class AbstractImage : Image { // make sealed in 1.3.0 ?
|
||||
@Deprecated(
|
||||
"""
|
||||
不要自行实现 Image, 它必须由协议模块实现, 否则会无法发送也无法解析.
|
||||
""", level = DeprecationLevel.HIDDEN
|
||||
)
|
||||
@Suppress("PropertyName", "DeprecatedCallableAddReplaceWith")
|
||||
@get:JvmSynthetic
|
||||
final override val DoNotImplementThisClass: Nothing?
|
||||
get() = error("stub")
|
||||
|
||||
private var _stringValue: String? = null
|
||||
get() = field ?: kotlin.run {
|
||||
field = "[mirai:image:$imageId]"
|
||||
field
|
||||
}
|
||||
|
||||
final override fun toString(): String = _stringValue!!
|
||||
final override fun contentToString(): String = "[图片]"
|
||||
}
|
||||
|
||||
internal interface ConstOriginUrlAware : Image {
|
||||
val originUrl: String
|
||||
}
|
||||
|
||||
internal interface DeferredOriginUrlAware : Image {
|
||||
fun getUrl(bot: Bot): String
|
||||
}
|
||||
|
||||
internal interface SuspendDeferredOriginUrlAware : Image {
|
||||
suspend fun getUrl(bot: Bot): String
|
||||
}
|
||||
|
||||
/**
|
||||
* 由 [ExternalImage] 委托的 [Image] 类型.
|
||||
*/
|
||||
@SinceMirai("1.1.0")
|
||||
@MiraiExperimentalAPI("Will be renamed to OfflineImage on 1.2.0")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
internal class ExperimentalDeferredImage internal constructor(
|
||||
@Suppress("CanBeParameter") private val externalImage: ExternalImage // for future use
|
||||
) : AbstractImage(), SuspendDeferredOriginUrlAware {
|
||||
override suspend fun getUrl(bot: Bot): String {
|
||||
TODO()
|
||||
}
|
||||
|
||||
override val imageId: String = externalImage.calculateImageResourceId()
|
||||
}
|
||||
|
||||
internal val firstOnlineBotInstance: Bot get() = Bot.botInstancesSequence.firstOrNull() ?: error("No Bot available")
|
||||
|
||||
// endergion
|
||||
|
||||
/////////////////////////
|
||||
//// IMPLEMENTATIONS ////
|
||||
/////////////////////////
|
||||
@ -199,7 +140,7 @@ internal fun Sequence<SingleMessage>.constrainSingleMessages(): List<SingleMessa
|
||||
}
|
||||
}
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@JvmSynthetic
|
||||
internal inline fun constrainSingleMessagesImpl(iterator: () -> SingleMessage?): ArrayList<SingleMessage> {
|
||||
val list = ArrayList<SingleMessage>()
|
||||
@ -255,8 +196,8 @@ internal fun <M : Message> MessageChain.firstOrNullImpl(key: Message.Key<M>): M?
|
||||
AtAll -> firstIsInstanceOrNull<AtAll>()
|
||||
PlainText -> firstIsInstanceOrNull<PlainText>()
|
||||
Image -> firstIsInstanceOrNull<Image>()
|
||||
OnlineImage -> firstIsInstanceOrNull<OnlineImage>()
|
||||
OfflineImage -> firstIsInstanceOrNull<OfflineImage>()
|
||||
// OnlineImage -> firstIsInstanceOrNull<OnlineImage>()
|
||||
// OfflineImage -> firstIsInstanceOrNull<OfflineImage>()
|
||||
GroupImage -> firstIsInstanceOrNull<GroupImage>()
|
||||
FriendImage -> firstIsInstanceOrNull<FriendImage>()
|
||||
Face -> firstIsInstanceOrNull<Face>()
|
||||
@ -412,7 +353,8 @@ internal fun calculateImageMd5ByImageId(imageId: String): ByteArray {
|
||||
}
|
||||
}
|
||||
|
||||
internal val ILLEGAL_IMAGE_ID_EXCEPTION_MESSAGE =
|
||||
@PublishedApi
|
||||
internal val ILLEGAL_IMAGE_ID_EXCEPTION_MESSAGE: String =
|
||||
"ImageId must match Regex `${FRIEND_IMAGE_ID_REGEX_1.pattern}`, " +
|
||||
"`${FRIEND_IMAGE_ID_REGEX_2.pattern}` or " +
|
||||
"`${GROUP_IMAGE_ID_REGEX.pattern}`"
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -12,8 +12,8 @@
|
||||
package net.mamoe.mirai.network
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.MiraiInternalApi
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
|
||||
/**
|
||||
@ -31,14 +31,14 @@ public sealed class LoginFailedException(
|
||||
/**
|
||||
* 密码输入错误 (有时候也会是其他错误, 如 `"当前上网环境异常,请更换网络环境或在常用设备上登录或稍后再试。"`)
|
||||
*/
|
||||
public class WrongPasswordException @MiraiInternalAPI constructor(
|
||||
public class WrongPasswordException @MiraiInternalApi constructor(
|
||||
message: String?
|
||||
) : LoginFailedException(true, message)
|
||||
|
||||
/**
|
||||
* 无可用服务器
|
||||
*/
|
||||
public class NoServerAvailableException @MiraiInternalAPI constructor(
|
||||
public class NoServerAvailableException @MiraiInternalApi constructor(
|
||||
public override val cause: Throwable?
|
||||
) : LoginFailedException(false, "no server available")
|
||||
|
||||
@ -46,20 +46,20 @@ public class NoServerAvailableException @MiraiInternalAPI constructor(
|
||||
* 服务器要求稍后重试
|
||||
*/
|
||||
@SinceMirai("1.2.0")
|
||||
public class RetryLaterException @MiraiInternalAPI constructor() :
|
||||
public class RetryLaterException @MiraiInternalApi constructor() :
|
||||
LoginFailedException(false, "server requests retrial later")
|
||||
|
||||
/**
|
||||
* 无标准输入或 Kotlin 不支持此输入.
|
||||
*/
|
||||
public class NoStandardInputForCaptchaException @MiraiInternalAPI constructor(
|
||||
public class NoStandardInputForCaptchaException @MiraiInternalApi constructor(
|
||||
public override val cause: Throwable?
|
||||
) : LoginFailedException(true, "no standard input for captcha")
|
||||
|
||||
/**
|
||||
* 需要短信验证时抛出. mirai 目前还不支持短信验证.
|
||||
*/
|
||||
@MiraiExperimentalAPI("Will be removed when SMS login is supported")
|
||||
@MiraiExperimentalApi("Will be removed when SMS login is supported")
|
||||
public class UnsupportedSMSLoginException(message: String?) : LoginFailedException(true, message)
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -24,7 +24,7 @@ import kotlin.annotation.AnnotationTarget.*
|
||||
CLASS, FUNCTION, PROPERTY
|
||||
)
|
||||
@MustBeDocumented
|
||||
public annotation class MiraiInternalAPI(
|
||||
public annotation class MiraiInternalApi(
|
||||
public val message: String = ""
|
||||
)
|
||||
|
||||
@ -38,7 +38,7 @@ public annotation class MiraiInternalAPI(
|
||||
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
|
||||
@Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR)
|
||||
@MustBeDocumented
|
||||
public annotation class MiraiExperimentalAPI(
|
||||
public annotation class MiraiExperimentalApi(
|
||||
public val message: String = ""
|
||||
)
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -148,14 +148,14 @@ public open class BotConfigurationBase internal constructor() {
|
||||
|
||||
/** 缓存策略 */
|
||||
@SinceMirai("1.0.0")
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public var fileCacheStrategy: FileCacheStrategy = FileCacheStrategy.PlatformDefault
|
||||
|
||||
/**
|
||||
* Json 序列化器, 使用 'kotlinx.serialization'
|
||||
*/
|
||||
@SinceMirai("1.1.0")
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public var json: Json = kotlin.runCatching {
|
||||
@OptIn(UnstableDefault::class)
|
||||
Json {
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -28,7 +28,7 @@ import kotlin.jvm.JvmName
|
||||
* 从接收者管道读取所有数据并写入 [dst]. 不会关闭 [dst]
|
||||
*/
|
||||
@OptIn(InternalSerializationApi::class)
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public suspend fun ByteReadChannel.copyTo(dst: OutputStream) {
|
||||
val buffer = ByteArray(2048)
|
||||
var size: Int
|
||||
@ -40,7 +40,7 @@ public suspend fun ByteReadChannel.copyTo(dst: OutputStream) {
|
||||
/**
|
||||
* 从接收者管道读取所有数据并写入 [dst]. 不会关闭 [dst]
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public suspend fun ByteReadChannel.copyTo(dst: Output) {
|
||||
val buffer = ByteArray(2048)
|
||||
var size: Int
|
||||
@ -52,7 +52,7 @@ public suspend fun ByteReadChannel.copyTo(dst: Output) {
|
||||
/**
|
||||
* 从接收者管道读取所有数据并写入 [dst]. 不会关闭 [dst]
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public suspend fun ByteReadChannel.copyTo(dst: ByteWriteChannel) {
|
||||
val buffer = ByteArray(2048)
|
||||
var size: Int
|
||||
@ -67,7 +67,7 @@ public suspend fun ByteReadChannel.copyTo(dst: ByteWriteChannel) {
|
||||
/**
|
||||
* 从接收者管道读取所有数据并写入 [dst], 最终关闭 [dst]
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@OptIn(InternalSerializationApi::class)
|
||||
public suspend fun ByteReadChannel.copyAndClose(dst: OutputStream) { // 在 JVM 这个 API 不是 internal 的
|
||||
try {
|
||||
@ -84,7 +84,7 @@ public suspend fun ByteReadChannel.copyAndClose(dst: OutputStream) { // 在 JVM
|
||||
/**
|
||||
* 从接收者管道读取所有数据并写入 [dst], 最终关闭 [dst]
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public suspend fun ByteReadChannel.copyAndClose(dst: Output) {
|
||||
try {
|
||||
val buffer = ByteArray(2048)
|
||||
@ -100,7 +100,7 @@ public suspend fun ByteReadChannel.copyAndClose(dst: Output) {
|
||||
/**
|
||||
* 从接收者管道读取所有数据并写入 [dst], 最终关闭 [dst]
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public suspend fun ByteReadChannel.copyAndClose(dst: ByteWriteChannel) {
|
||||
@Suppress("DuplicatedCode")
|
||||
try {
|
||||
@ -118,7 +118,7 @@ public suspend fun ByteReadChannel.copyAndClose(dst: ByteWriteChannel) {
|
||||
/**
|
||||
* 从接收者管道读取所有数据并写入 [dst], 最终关闭 [dst]
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public suspend fun ByteReadChannel.copyAndClose(dst: io.ktor.utils.io.ByteWriteChannel) {
|
||||
@Suppress("DuplicatedCode")
|
||||
try {
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -69,12 +69,12 @@ public class ExternalImage internal constructor(
|
||||
public const val defaultFormatName: String = "mirai"
|
||||
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public fun generateUUID(md5: ByteArray): String {
|
||||
return "${md5[0, 3]}-${md5[4, 5]}-${md5[6, 7]}-${md5[8, 9]}-${md5[10, 15]}"
|
||||
}
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public fun generateImageId(md5: ByteArray): String {
|
||||
return """{${generateUUID(md5)}}.$defaultFormatName"""
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
@ -21,13 +21,13 @@ import kotlin.contracts.contract
|
||||
*
|
||||
* 图片上传时默认使用文件缓存.
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public expect interface FileCacheStrategy {
|
||||
/**
|
||||
* 将 [input] 缓存为 [ExternalImage].
|
||||
* 此函数应 close 这个 [Input]
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@Throws(IOException::class)
|
||||
public fun newImageCache(input: Input): ExternalImage
|
||||
|
||||
@ -35,25 +35,25 @@ public expect interface FileCacheStrategy {
|
||||
* 将 [input] 缓存为 [ExternalImage].
|
||||
* 此 [input] 的内容应是不变的.
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@Throws(IOException::class)
|
||||
public fun newImageCache(input: ByteArray): ExternalImage
|
||||
|
||||
/**
|
||||
* 默认的缓存方案. 在 JVM 平台使用系统临时文件.
|
||||
*/
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
public object PlatformDefault : FileCacheStrategy
|
||||
|
||||
/**
|
||||
* 使用内存直接存储所有图片文件.
|
||||
*/
|
||||
public object MemoryCache : FileCacheStrategy {
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@Throws(IOException::class)
|
||||
public override fun newImageCache(input: Input): ExternalImage
|
||||
|
||||
@MiraiExperimentalAPI
|
||||
@MiraiExperimentalApi
|
||||
@Throws(IOException::class)
|
||||
public override fun newImageCache(input: ByteArray): ExternalImage
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user