diff --git a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/GroupManageRouteModule.kt b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/GroupManageRouteModule.kt index 645cb741e..21e4fe021 100644 --- a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/GroupManageRouteModule.kt +++ b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/GroupManageRouteModule.kt @@ -19,12 +19,12 @@ fun Application.groupManageModule() { * 禁言(需要相关权限) */ miraiVerify("/muteAll") { - it.session.bot.getGroup(it.target).muteAll = true + it.session.bot.getGroup(it.target).isMuteAll = true call.respondStateCode(StateCode.Success) } miraiVerify("/unmuteAll") { - it.session.bot.getGroup(it.target).muteAll = false + it.session.bot.getGroup(it.target).isMuteAll = false call.respondStateCode(StateCode.Success) } @@ -65,8 +65,8 @@ fun Application.groupManageModule() { with(dto.config) { name?.let { group.name = it } announcement?.let { group.entranceAnnouncement = it } - confessTalk?.let { group.confessTalk = it } - allowMemberInvite?.let { group.allowMemberInvite = it } + confessTalk?.let { group.isConfessTalkEnabled = it } + allowMemberInvite?.let { group.isAllowMemberInvite = it } // TODO: 待core接口实现设置可改 // autoApprove?.let { group.autoApprove = it } // anonymousChat?.let { group.anonymousChat = it } @@ -128,8 +128,8 @@ private data class GroupDetailDTO( val anonymousChat: Boolean? = null ) : DTO { constructor(group: Group) : this( - group.name, group.entranceAnnouncement, group.confessTalk, group.allowMemberInvite, - group.autoApprove, group.anonymousChat + group.name, group.entranceAnnouncement, group.isConfessTalkEnabled, group.isAllowMemberInvite, + group.isAutoApproveEnabled, group.isAnonymousChatEnabled ) } diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt index 259fe6591..a933dcfdf 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt @@ -394,7 +394,7 @@ internal class GroupImpl( } - override var allowMemberInvite: Boolean + override var isAllowMemberInvite: Boolean get() = _allowMemberInvite set(newValue) { this.checkBotPermissionOperator() @@ -414,19 +414,19 @@ internal class GroupImpl( } } - override var autoApprove: Boolean + override var isAutoApproveEnabled: Boolean get() = _autoApprove set(newValue) { TODO() } - override var anonymousChat: Boolean + override var isAnonymousChatEnabled: Boolean get() = _anonymousChat set(newValue) { TODO() } - override var confessTalk: Boolean + override var isConfessTalkEnabled: Boolean get() = _confessTalk set(newValue) { this.checkBotPermissionOperator() @@ -447,7 +447,7 @@ internal class GroupImpl( } - override var muteAll: Boolean + override var isMuteAll: Boolean get() = _muteAll set(newValue) { this.checkBotPermissionOperator() diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt index 5b2bd3fe2..87afe2054 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt @@ -180,14 +180,14 @@ internal class OnlinePush { return if (target == 0L) { if (time == 0) { GroupMuteAllEvent( - origin = group.muteAll.also { group._muteAll = false }, + origin = group.isMuteAll.also { group._muteAll = false }, new = false, operator = operator, group = group ) } else { GroupMuteAllEvent( - origin = group.muteAll.also { group._muteAll = true }, + origin = group.isMuteAll.also { group._muteAll = true }, new = true, operator = operator, group = group @@ -213,7 +213,7 @@ internal class OnlinePush { val operator = group[this.readUInt().toLong()] val switch = this.readInt() == 0 return GroupAllowAnonymousChatEvent( - origin = group.anonymousChat.also { group._anonymousChat = switch }, + origin = group.isAnonymousChatEnabled.also { group._anonymousChat = switch }, new = switch, operator = operator, group = group @@ -236,7 +236,7 @@ internal class OnlinePush { when (message) { "管理员已关闭群聊坦白说" -> { return GroupAllowConfessTalkEvent( - origin = group.confessTalk.also { group._confessTalk = false }, + origin = group.isConfessTalkEnabled.also { group._confessTalk = false }, new = false, group = group, isByBot = false @@ -244,7 +244,7 @@ internal class OnlinePush { } "管理员已开启群聊坦白说" -> { return GroupAllowConfessTalkEvent( - origin = group.confessTalk.also { group._confessTalk = true }, + origin = group.isConfessTalkEnabled.also { group._confessTalk = true }, new = true, group = group, isByBot = false diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt index 42a96bec4..80c2900bc 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt @@ -38,8 +38,8 @@ interface Contact : CoroutineScope { /** * 可以是 QQ 号码或者群号码. * - * 对于 QQ, `uin` 与 `id` 是相同的意思. - * 对于 Group, `groupCode` 与 `id` 是相同的意思. + * 对于 [QQ], `uin` 与 `id` 是相同的意思. + * 对于 [Group], `groupCode` 与 `id` 是相同的意思. */ val id: Long diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt index b5dace4d2..c705ef844 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt @@ -46,8 +46,9 @@ interface Group : Contact, CoroutineScope { * 当前仅能修改状态. * * @see GroupMuteAllEvent - */// TODO: 2020/2/5 实现 muteAll 的查询 - var muteAll: Boolean + * @throws PermissionDeniedException 无权限修改时将会抛出异常 + */ + var isMuteAll: Boolean /** * 坦白说状态. `true` 为允许. * @@ -56,7 +57,7 @@ interface Group : Contact, CoroutineScope { * @see GroupAllowConfessTalkEvent * @throws PermissionDeniedException 无权限修改时将会抛出异常 */ - var confessTalk: Boolean + var isConfessTalkEnabled: Boolean /** * 允许群员邀请好友入群的状态. `true` 为允许 * @@ -65,15 +66,15 @@ interface Group : Contact, CoroutineScope { * @see GroupAllowMemberInviteEvent * @throws PermissionDeniedException 无权限修改时将会抛出异常 */ - var allowMemberInvite: Boolean + var isAllowMemberInvite: Boolean /** * 自动加群审批 */ - val autoApprove: Boolean + val isAutoApproveEnabled: Boolean /** * 匿名聊天 */ - val anonymousChat: Boolean + val isAnonymousChatEnabled: Boolean /** * 同为 groupCode, 用户看到的群号码. diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Permission.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Permission.kt index c064535e6..ac1137744 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Permission.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Permission.kt @@ -72,9 +72,9 @@ inline fun Member.isOperator(): Boolean = this.permission.isOperator() /** * 权限不足 */ -class PermissionDeniedException : IllegalStateException { - constructor() : super("Permission denied") - constructor(message: String?) : super(message) +expect class PermissionDeniedException : IllegalStateException { + constructor() + constructor(message: String?) } @UseExperimental(MiraiExperimentalAPI::class) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt index 9047df8e0..a855e40b2 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt @@ -22,11 +22,11 @@ import net.mamoe.mirai.utils.MiraiExperimentalAPI @Suppress("unused") -class EventCancelledException : RuntimeException { - constructor() : super() - constructor(message: String?) : super(message) - constructor(message: String?, cause: Throwable?) : super(message, cause) - constructor(cause: Throwable?) : super(cause) +expect class EventCancelledException : RuntimeException { + constructor() + constructor(message: String?) + constructor(message: String?, cause: Throwable?) + constructor(cause: Throwable?) } // note: 若你使用 IntelliJ IDEA, 按 alt + 7 可打开结构