Список параметров для метода Messages.Get
Esempio n. 1
0
 /// <summary>
 /// Привести к типу VkParameters.
 /// </summary>
 /// <param name="p">Параметры.</param>
 /// <returns></returns>
 public static VkParameters ToVkParameters(MessagesGetParams p)
 {
     return(new VkParameters
     {
         { "offset", p.Offset },
         { "count", p.Count },
         { "time_offset", p.TimeOffset },
         { "filters", p.Filters },
         { "preview_length", p.PreviewLength },
         { "last_message_id", p.LastMessageId }
     });
 }
Esempio n. 2
0
		/// <summary>
		/// Привести к типу VkParameters.
		/// </summary>
		/// <param name="p">Параметры.</param>
		/// <returns></returns>
		internal static VkParameters ToVkParameters(MessagesGetParams p)
        {
            return new VkParameters
            {
                { "out", p.Out },
                { "offset", p.Offset },
                { "count", p.Count },
                { "time_offset", p.TimeOffset },
                { "filters", p.Filters },
                { "preview_length", p.PreviewLength },
                { "last_message_id", p.LastMessageId }
            };
        }
Esempio n. 3
0
        public ReadOnlyCollection<Message> Get(
            MessageType type,
            out int totalCount,
            uint? count = 20,
            uint? offset = null,
            TimeSpan? timeOffset = null,
            MessagesFilter? filter = null,
            uint? previewLength = 0,
            long? lastMessageId = null)
        {
            var parameters = new MessagesGetParams
            {
                Out = type,
                Offset = offset,
                Filters = filter,
                PreviewLength = previewLength,
                LastMessageId = lastMessageId
            };

            var response = _vk.Call("messages.get", parameters);
            totalCount = response["count"];

            return Get(parameters).Messages;
        }
        // Получение сообщений и составление списка userIdsToGet
        /// <summary>
        /// Receives the messages.
        /// </summary>
        /// <param name="userIdsToGet">The user ids to get.</param>
        /// <param name="vkMessages">The vk messages.</param>
        /// <returns></returns>
        bool ReceiveMessages(List<long> userIdsToGet, ref MessagesGetObject vkMessages)
        {
            if (userIdsToGet == null) return false;
            MessagesGetParams vkMsgParams = new MessagesGetParams();

            vkMsgParams.Count = 100;
            vkMsgParams.Offset = 0;
            vkMsgParams.TimeOffset = 0;
            vkMsgParams.Filters = MessagesFilter.All;

            try
            {
                vkMessages = vk.Messages.Get(vkMsgParams);//vk.Messages.Get(0, out offset, 100, 0, new TimeSpan(0), 0);
            }
            catch (Exception)
            {
                return false;
            }

            // Составление списка userIdsToGet (id пользователей, которых надо получить с сервера) из сообщений
            foreach (var vkMessage in vkMessages.Messages)
            {
                long vkMessageUserId;

                if (vkMessage.UserId.HasValue)
                {
                    vkMessageUserId = vkMessage.UserId.Value;

                    if ((!usersDict.ContainsKey(vkMessageUserId)) && (!userIdsToGet.Contains(vkMessageUserId)))
                        userIdsToGet.Add(vkMessageUserId);
                }
            }
            return true;
        }