From c966d9840ea7794507039fe0b0b87b01020ac45e Mon Sep 17 00:00:00 2001
From: Karlatemp <karlatemp@vip.qq.com>
Date: Wed, 30 Dec 2020 23:23:33 +0800
Subject: [PATCH] Fix Bot.getFriend

---
 mirai-core-api/src/commonMain/kotlin/Bot.kt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mirai-core-api/src/commonMain/kotlin/Bot.kt b/mirai-core-api/src/commonMain/kotlin/Bot.kt
index fac2ef9f2..e4b151838 100644
--- a/mirai-core-api/src/commonMain/kotlin/Bot.kt
+++ b/mirai-core-api/src/commonMain/kotlin/Bot.kt
@@ -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].