Rename OPERATOR to ADMINISTRATOR, add extensions

This commit is contained in:
Him188 2019-12-03 20:25:44 +08:00
parent b4b0559c2f
commit d5dd86549b
2 changed files with 21 additions and 2 deletions

View File

@ -70,9 +70,28 @@ enum class MemberPermission {
/**
* 管理员
*/
OPERATOR,
ADMINISTRATOR,
/**
* 一般群成员
*/
MEMBER;
}
@Suppress("NOTHING_TO_INLINE")
inline fun MemberPermission.isOwner(): Boolean = this == MemberPermission.OWNER
@Suppress("NOTHING_TO_INLINE")
inline fun MemberPermission.isAdministrator(): Boolean = this == MemberPermission.ADMINISTRATOR
@Suppress("NOTHING_TO_INLINE")
inline fun MemberPermission.isAdministratorOrOwner(): Boolean = isAdministrator() || isOwner()
@Suppress("NOTHING_TO_INLINE")
inline fun Member.isOwner(): Boolean = this.permission.isOwner()
@Suppress("NOTHING_TO_INLINE")
inline fun Member.isAdministrator(): Boolean = this.permission.isAdministrator()
@Suppress("NOTHING_TO_INLINE")
inline fun Member.isAdministratorOrOwner(): Boolean = this.permission.isAdministratorOrOwner()

View File

@ -202,7 +202,7 @@ object GroupPacket : SessionPacketFactory<GroupPacket.GroupPacketResponse>() {
}
val permission = when (status.takeLowestOneBit()) {
1 -> MemberPermission.OPERATOR
1 -> MemberPermission.ADMINISTRATOR
else -> MemberPermission.MEMBER
}
members[qq] = permission