コード例 #1
0
        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);
        }
コード例 #2
0
 /// <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
     }));
 }