From 3a4cb9e02564351886e030d71fab790ba34fa066 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Thu, 19 Dec 2019 12:26:52 +0100 Subject: [PATCH] fix crash --- telegram/Util.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/telegram/Util.cs b/telegram/Util.cs index 879352f..77c1f5e 100644 --- a/telegram/Util.cs +++ b/telegram/Util.cs @@ -287,10 +287,8 @@ namespace telegram { if (results.ChatIds.Length == 0) return 0; - return results.ChatIds.Select(GetChat) - .Where(p => p.Type is ChatType.ChatTypePrivate) - .Select(p => ((ChatType.ChatTypePrivate) p.Type).UserId) - .First(); + var output = results.ChatIds.Select(GetChat).Where(p => p.Type is ChatType.ChatTypePrivate).Select(p => ((ChatType.ChatTypePrivate) p.Type).UserId); + return output.Any() ? output.First() : 0; } public static int SearchContacts(string query) {