public bool TryGetScope(Chat chat, out ScopeNotificationSettings value) { Type scope = null; switch (chat.Type) { case ChatTypePrivate: case ChatTypeSecret: scope = typeof(NotificationSettingsScopePrivateChats); break; case ChatTypeBasicGroup: scope = typeof(NotificationSettingsScopeGroupChats); break; case ChatTypeSupergroup supergroup: scope = supergroup.IsChannel ? typeof(NotificationSettingsScopeChannelChats) : typeof(NotificationSettingsScopeGroupChats); break; } if (scope != null && _scopeNotificationSettings.TryGetValue(scope, out value)) { return(true); } value = null; return(false); }
/// <summary> /// Changes notification settings for chats of a given type /// </summary> public static Task <Ok> SetScopeNotificationSettingsAsync( this Client client, NotificationSettingsScope scope = default, ScopeNotificationSettings notificationSettings = default) { return(client.ExecuteAsync(new SetScopeNotificationSettings { Scope = scope, NotificationSettings = notificationSettings })); }