From 510a041f0c2d281a575c42686c69a4e452876e21 Mon Sep 17 00:00:00 2001 From: ryoii Date: Fri, 26 Jun 2020 19:51:10 +0800 Subject: [PATCH] Close #393 --- .../net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt | 11 +++++++---- .../network/protocol/packet/chat/NewContact.kt | 5 +++-- .../src/commonMain/kotlin/net.mamoe.mirai/Bot.kt | 2 +- .../kotlin/net.mamoe.mirai/event/events/group.kt | 6 +++--- .../commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt index ee86d2f1c..0f8e93afc 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt @@ -146,7 +146,7 @@ internal class QQAndroidBot constructor( @Suppress("DuplicatedCode") @OptIn(LowLevelAPI::class) - override suspend fun rejectMemberJoinRequest(event: MemberJoinRequestEvent, blackList: Boolean) { + override suspend fun rejectMemberJoinRequest(event: MemberJoinRequestEvent, blackList: Boolean, message: String) { checkGroupPermission(event.bot, event.group) { event::class.simpleName ?: "" } check(event.responded.compareAndSet(false, true)) { "the request $this has already been responded" @@ -162,7 +162,8 @@ internal class QQAndroidBot constructor( fromNick = event.fromNick, groupId = event.groupId, accept = false, - blackList = blackList + blackList = blackList, + message = message ) } @@ -755,7 +756,8 @@ internal abstract class QQAndroidBotBase constructor( fromNick: String, groupId: Long, accept: Boolean?, - blackList: Boolean + blackList: Boolean, + message: String ) { network.apply { NewContact.SystemMsgNewGroup.Action( @@ -765,7 +767,8 @@ internal abstract class QQAndroidBotBase constructor( groupId = groupId, isInvited = false, accept = accept, - blackList = blackList + blackList = blackList, + message = message ).sendWithoutExpect() groups[groupId].apply { members.delegate.addLast(newMember(object : MemberInfo { diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/NewContact.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/NewContact.kt index 7ea8fdafe..f6d8b7ba1 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/NewContact.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/NewContact.kt @@ -223,7 +223,8 @@ internal class NewContact { groupId: Long, isInvited: Boolean, accept: Boolean?, - blackList: Boolean = false + blackList: Boolean = false, + message: String = "" ) = buildOutgoingUniPacket(client) { writeProtoBuf( @@ -236,7 +237,7 @@ internal class NewContact { false -> 12 // reject }, groupCode = groupId, - msg = "", + msg = message, remark = "", blacklist = blackList ), diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt index d48d84a8c..54f187f41 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt @@ -295,7 +295,7 @@ abstract class Bot internal constructor( level = DeprecationLevel.ERROR ) @JvmSynthetic - abstract suspend fun rejectMemberJoinRequest(event: MemberJoinRequestEvent, blackList: Boolean = false) + abstract suspend fun rejectMemberJoinRequest(event: MemberJoinRequestEvent, blackList: Boolean = false, message: String = "") /** * 忽略加群验证(需管理员权限) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/group.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/group.kt index 17c753b62..700e769e6 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/group.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/group.kt @@ -353,7 +353,7 @@ data class MemberJoinRequestEvent internal constructor( suspend fun accept() = bot.acceptMemberJoinRequest(this) @JvmSynthetic - suspend fun reject(blackList: Boolean = false) = bot.rejectMemberJoinRequest(this, blackList) + suspend fun reject(blackList: Boolean = false, message: String = "") = bot.rejectMemberJoinRequest(this, blackList, message) @JvmSynthetic suspend fun ignore(blackList: Boolean = false) = bot.ignoreMemberJoinRequest(this, blackList) @@ -366,8 +366,8 @@ data class MemberJoinRequestEvent internal constructor( @JavaFriendlyAPI @JvmOverloads @JvmName("reject") - fun __rejectBlockingForJava__(blackList: Boolean = false) = - runBlocking { bot.rejectMemberJoinRequest(this@MemberJoinRequestEvent, blackList) } + fun __rejectBlockingForJava__(blackList: Boolean = false, message: String = "") = + runBlocking { bot.rejectMemberJoinRequest(this@MemberJoinRequestEvent, blackList, message) } @JavaFriendlyAPI @JvmOverloads diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt index 00be90391..8f97341b6 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt @@ -137,5 +137,5 @@ interface LowLevelBotAPIAccessor { */ @LowLevelAPI @MiraiExperimentalAPI - suspend fun _lowLevelSolveMemberJoinRequestEvent(eventId: Long, fromId: Long, fromNick: String, groupId: Long, accept: Boolean?, blackList: Boolean) + suspend fun _lowLevelSolveMemberJoinRequestEvent(eventId: Long, fromId: Long, fromNick: String, groupId: Long, accept: Boolean?, blackList: Boolean, message: String = "") }