Misc improvements

This commit is contained in:
Him188 2020-03-24 15:45:49 +08:00
parent 83793d3f7e
commit 5dc0475a73
4 changed files with 17 additions and 19 deletions

View File

@ -39,11 +39,11 @@ import kotlin.coroutines.CoroutineContext
import kotlin.jvm.JvmSynthetic
@OptIn(ExperimentalContracts::class)
internal fun GroupImpl.Companion.checkIsInstance(expression: Boolean) {
internal fun GroupImpl.Companion.checkIsInstance(instance: Group) {
contract {
returns() implies expression
returns() implies (instance is GroupImpl)
}
check(expression) { "group is not an instanceof GroupImpl!! DO NOT interlace two or more protocol implementations!!" }
check(instance is GroupImpl) { "group is not an instanceof GroupImpl!! DO NOT interlace two or more protocol implementations!!" }
}
@Suppress("PropertyName")

View File

@ -197,7 +197,7 @@ internal class OnlinePush {
when (msgInfo.shMsgType.toInt()) {
732 -> {
val group = bot.getGroup(this.readUInt().toLong())
GroupImpl.checkIsInstance(group is GroupImpl)
GroupImpl.checkIsInstance(group)
when (val internalType = this.readByte().toInt().also { this.discardExact(1) }) {
0x0c -> { // mute
@ -215,7 +215,7 @@ internal class OnlinePush {
if (time == 0) {
return@flatMap sequenceOf(
GroupMuteAllEvent(
origin = group.isMuteAll.also { group._muteAll = false },
origin = group.settings.isMuteAll.also { group._muteAll = false },
new = false,
operator = operator,
group = group
@ -224,7 +224,7 @@ internal class OnlinePush {
} else {
return@flatMap sequenceOf(
GroupMuteAllEvent(
origin = group.isMuteAll.also { group._muteAll = true },
origin = group.settings.isMuteAll.also { group._muteAll = true },
new = true,
operator = operator,
group = group
@ -283,7 +283,7 @@ internal class OnlinePush {
val switch = this.readInt() == 0
return@flatMap sequenceOf(
GroupAllowAnonymousChatEvent(
origin = group.isAnonymousChatEnabled.also {
origin = group.settings.isAnonymousChatEnabled.also {
group._anonymousChat = switch
},
new = switch,
@ -312,7 +312,7 @@ internal class OnlinePush {
"管理员已关闭群聊坦白说" -> {
return@flatMap sequenceOf(
GroupAllowConfessTalkEvent(
origin = group.isConfessTalkEnabled.also {
origin = group.settings.isConfessTalkEnabled.also {
group._confessTalk = false
},
new = false,
@ -324,7 +324,7 @@ internal class OnlinePush {
"管理员已开启群聊坦白说" -> {
return@flatMap sequenceOf(
GroupAllowConfessTalkEvent(
origin = group.isConfessTalkEnabled.also {
origin = group.settings.isConfessTalkEnabled.also {
group._confessTalk = true
},
new = true,

View File

@ -3,14 +3,13 @@ package net.mamoe.mirai.data
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import net.mamoe.mirai.utils.SinceMirai
/**
* 群统计信息
*
*
* */
*/
@SinceMirai("0.28.0")
@Serializable
data class GroupActiveData(

View File

@ -97,7 +97,7 @@ interface LowLevelBotAPIAccessor {
/**
* 获取群公告列表
* @param page 页码
* */
*/
@SinceMirai("0.28.0")
@LowLevelAPI
@MiraiExperimentalAPI
@ -107,7 +107,7 @@ interface LowLevelBotAPIAccessor {
* 发送群公告
*
* @return 公告的fid
* */
*/
@SinceMirai("0.28.0")
@LowLevelAPI
@MiraiExperimentalAPI
@ -117,7 +117,7 @@ interface LowLevelBotAPIAccessor {
/**
* 删除群公告
* @param fid [GroupAnnouncement.fid]
* */
*/
@SinceMirai("0.28.0")
@LowLevelAPI
@MiraiExperimentalAPI
@ -126,7 +126,7 @@ interface LowLevelBotAPIAccessor {
/**
* 获取一条群公告
* @param fid [GroupAnnouncement.fid]
* */
*/
@SinceMirai("0.28.0")
@LowLevelAPI
@MiraiExperimentalAPI
@ -135,8 +135,7 @@ interface LowLevelBotAPIAccessor {
/**
* 获取群活跃信息
*
* */
*/
@LowLevelAPI
@MiraiExperimentalAPI
suspend fun _lowLevelGetGroupActiveData(groupId: Long): GroupActiveData