diff --git a/tgcli/Util.cs b/tgcli/Util.cs index 79ab9a7..cd09573 100644 --- a/tgcli/Util.cs +++ b/tgcli/Util.cs @@ -101,17 +101,19 @@ namespace tgcli { return history; } - + public static bool IsMuted(Chat c) { if (c.NotificationSettings.MuteFor == 0 && !c.NotificationSettings.UseDefaultMuteFor) return false; NotificationSettingsScope scope = c.Type switch { ChatType.ChatTypeBasicGroup => new NotificationSettingsScope.NotificationSettingsScopeGroupChats(), - ChatType.ChatTypeSupergroup => new NotificationSettingsScope.NotificationSettingsScopeGroupChats(), - ChatType.ChatTypePrivate => new NotificationSettingsScope.NotificationSettingsScopePrivateChats(), - ChatType.ChatTypeSecret => new NotificationSettingsScope.NotificationSettingsScopePrivateChats(), - _ => throw new ArgumentOutOfRangeException() + ChatType.ChatTypeSupergroup t => t.IsChannel + ? new NotificationSettingsScope.NotificationSettingsScopeChannelChats() + : new NotificationSettingsScope.NotificationSettingsScopeGroupChats(), + ChatType.ChatTypePrivate => new NotificationSettingsScope.NotificationSettingsScopePrivateChats(), + ChatType.ChatTypeSecret => new NotificationSettingsScope.NotificationSettingsScopePrivateChats(), + _ => throw new ArgumentOutOfRangeException() }; return client.GetScopeNotificationSettingsAsync(scope).Result.MuteFor != 0; @@ -123,9 +125,7 @@ namespace tgcli { var response = client.ExecuteAsync(new GetChats { Limit = int.MaxValue }).Result; output.AddRange(all ? response.ChatIds.Select(GetChat).Where(c => c.UnreadCount > 0 || c.IsMarkedAsUnread).ToList() - : response.ChatIds.Select(GetChat) - .Where(c => (c.UnreadCount > 0 || c.IsMarkedAsUnread) && !IsMuted(c)) - .ToList()); + : response.ChatIds.Select(GetChat).Where(c => (c.UnreadCount > 0 || c.IsMarkedAsUnread) && !IsMuted(c)).ToList()); return output; }