Fix Bot.getFriend

This commit is contained in:
Karlatemp 2020-12-30 23:23:33 +08:00
parent 8e93a2c32f
commit c966d9840e
No known key found for this signature in database
GPG Key ID: 21FBDDF664FF06F8

View File

@ -103,7 +103,7 @@ public interface Bot : CoroutineScope, ContactOrBot, UserOrBot {
* [id] [Bot.id] 相同时返回 [Bot.asFriend]
*/
public fun getFriend(id: Long): Friend? =
friends.firstOrNull { it.id == id } ?: asFriend
friends.firstOrNull { it.id == id } ?: if (id == this.id) asFriend else null
/**
* [对方 QQ 号码][id] 获取一个好友对象, 在获取失败时抛出 [NoSuchElementException].