Skip to content

Commit

Permalink
Add UserOrBot.nameCardOrNick
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Mar 22, 2021
1 parent 146433d commit daa7453
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ public abstract interface class net/mamoe/mirai/contact/NormalMember : net/mamoe

public final class net/mamoe/mirai/contact/NormalMemberKt {
public static final fun getNameCardOrNick (Lnet/mamoe/mirai/contact/User;)Ljava/lang/String;
public static final fun getNameCardOrNick (Lnet/mamoe/mirai/contact/UserOrBot;)Ljava/lang/String;
public static final fun isMuted (Lnet/mamoe/mirai/contact/NormalMember;)Z
public static final fun mute-8Mi8wO0 (Lnet/mamoe/mirai/contact/NormalMember;DLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final synthetic fun mute-fcu0wV4 (Lnet/mamoe/mirai/contact/NormalMember;DLkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ public abstract interface class net/mamoe/mirai/contact/NormalMember : net/mamoe

public final class net/mamoe/mirai/contact/NormalMemberKt {
public static final fun getNameCardOrNick (Lnet/mamoe/mirai/contact/User;)Ljava/lang/String;
public static final fun getNameCardOrNick (Lnet/mamoe/mirai/contact/UserOrBot;)Ljava/lang/String;
public static final fun isMuted (Lnet/mamoe/mirai/contact/NormalMember;)Z
public static final fun mute-8Mi8wO0 (Lnet/mamoe/mirai/contact/NormalMember;DLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final synthetic fun mute-fcu0wV4 (Lnet/mamoe/mirai/contact/NormalMember;DLkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down
16 changes: 12 additions & 4 deletions mirai-core-api/src/commonMain/kotlin/contact/NormalMember.kt
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,25 @@ public interface NormalMember : Member {

/**
* 获取非空群名片或昵称.
*
* @return 当 [User] 为 [Member] 时返回 [Member.nameCardOrNick]
*
* 否则返回 [Member.nick]
* @return 当 [User] 为 [NormalMember] 时返回 [Member.nameCardOrNick], 否则返回 [Member.nick]
*/
public val User.nameCardOrNick: String
get() = when (this) {
is NormalMember -> this.nameCardOrNick
else -> this.nick
}

/**
* 获取非空群名片或昵称.
* @return 当 [UserOrBot] 为 [NormalMember] 时返回 [Member.nameCardOrNick], 否则返回 [Member.nick]
* @since 2.6
*/
public val UserOrBot.nameCardOrNick: String
get() = when (this) {
is NormalMember -> this.nameCardOrNick
else -> this.nick
}

/**
* 判断群成员是否处于禁言状态.
*/
Expand Down

0 comments on commit daa7453

Please sign in to comment.