mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-13 14:50:43 +08:00
Add Stranger.asFriend and Stranger.asFriendOrNull
This commit is contained in:
parent
33fc9c9daa
commit
32362f02c3
@ -579,6 +579,11 @@ public abstract interface class net/mamoe/mirai/contact/Stranger : kotlinx/corou
|
||||
public fun uploadImage (Lnet/mamoe/mirai/utils/ExternalResource;)Lnet/mamoe/mirai/message/data/Image;
|
||||
}
|
||||
|
||||
public final class net/mamoe/mirai/contact/StrangerKt {
|
||||
public static final fun asFriend (Lnet/mamoe/mirai/contact/Stranger;)Lnet/mamoe/mirai/contact/Friend;
|
||||
public static final fun asFriendOrNull (Lnet/mamoe/mirai/contact/Stranger;)Lnet/mamoe/mirai/contact/Friend;
|
||||
}
|
||||
|
||||
public abstract interface class net/mamoe/mirai/contact/TempUser : net/mamoe/mirai/contact/User {
|
||||
public fun queryProfile ()Lnet/mamoe/mirai/data/UserProfile;
|
||||
public fun sendMessage (Ljava/lang/String;)Lnet/mamoe/mirai/message/MessageReceipt;
|
||||
|
@ -91,4 +91,19 @@ public interface Stranger : User, CoroutineScope {
|
||||
* @see Nudge.sendTo 发送这个戳一戳消息
|
||||
*/
|
||||
public override fun nudge(): StrangerNudge = StrangerNudge(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 得到此陌生人作为好友的对象.
|
||||
*
|
||||
* @throws IllegalStateException 当此成员不是好友时抛出
|
||||
* @since 2.2
|
||||
*/
|
||||
public fun Stranger.asFriend(): Friend = this.bot.getFriend(this.id) ?: error("$this is not a friend")
|
||||
|
||||
/**
|
||||
* 得到此陌生人作为好友的对象, 当此成员不是好友时返回 `null`
|
||||
* @since 2.2
|
||||
*/
|
||||
public fun Stranger.asFriendOrNull(): Friend? = this.bot.getFriend(this.id)
|
||||
|
Loading…
Reference in New Issue
Block a user