コード例 #1
0
        private bool TryGetAutocomplete(string text, string query, out IAutocompleteCollection autocomplete)
        {
            if (Emoji.ContainsSingleEmoji(text) && ViewModel.ComposerHeader?.EditingMessage == null)
            {
                autocomplete = new SearchStickersCollection(ViewModel.ProtoService, ViewModel.Settings, text.Trim());
                return(true);
            }
            else if (SearchByUsername(query, out string username, out int index))
            {
                var chat = ViewModel.Chat;
                if (chat == null)
                {
                    autocomplete = null;
                    return(false);
                }

                var members = true;
                if (chat.Type is ChatTypePrivate || chat.Type is ChatTypeSecret || chat.Type is ChatTypeSupergroup supergroup && supergroup.IsChannel)
                {
                    members = false;
                }

                autocomplete = new UsernameCollection(ViewModel.ProtoService, ViewModel.Chat.Id, username, index == 0, members);
                return(true);
            }
コード例 #2
0
        private bool TryGetAutocomplete(string text, string query, out IAutocompleteCollection autocomplete)
        {
            if (Emoji.ContainsSingleEmoji(text) && ViewModel.ComposerHeader?.EditingMessage == null)
            {
                var chat = ViewModel.Chat;
                if (chat?.Permissions.CanSendOtherMessages == false)
                {
                    autocomplete = null;
                    return(false);
                }

                if (ViewModel.CacheService.TryGetSupergroup(chat, out Supergroup supergroup))
                {
                    if (supergroup.Status is ChatMemberStatusRestricted restricted && !restricted.Permissions.CanSendOtherMessages)
                    {
                        autocomplete = null;
                        return(false);
                    }
                }

                autocomplete = new SearchStickersCollection(ViewModel.ProtoService, ViewModel.Settings, text.Trim());
                return(true);
            }
            else if (SearchByUsername(query, out string username, out int index))
            {
                var chat = ViewModel.Chat;
                if (chat == null)
                {
                    autocomplete = null;
                    return(false);
                }

                var members = true;
                if (chat.Type is ChatTypePrivate || chat.Type is ChatTypeSecret || chat.Type is ChatTypeSupergroup supergroup && supergroup.IsChannel)
                {
                    members = false;
                }

                autocomplete = new UsernameCollection(ViewModel.ProtoService, ViewModel.Chat.Id, ViewModel.ThreadId, username, index == 0, members);
                return(true);
            }