Exemplo n.º 1
0
        public BotLikeTask ParseLikeTask(string html)
        {
            Regex regex = new Regex(@"do_like\((.+),(.+),(.+),'(.+)','(.+)','(.+)', (.+)\)");
            Match match = regex.Match(html);

            if (!match.Success)
            {
                return(null);
            }

            BotLikeTask task = new BotLikeTask
            {
                taskId  = match.Groups[1].Value,
                postId  = Convert.ToInt32(match.Groups[2].Value),
                ownerId = Convert.ToInt32(match.Groups[3].Value),
                type    = match.Groups[4].Value,
                postUrl = match.Groups[5].Value,
                repost  = match.Groups[6].Value,
                api     = match.Groups[7].Value
            };

            if (task.taskId == "'0'")
            {
                return(null);
            }

            return(task);
        }
Exemplo n.º 2
0
        private void HandleVideoLikeTask(BotLikeTask task)
        {
            Video video = new Video
            {
                OwnerId = task.ownerId,
                Id      = task.postId
            };

            if (_vkClient.AddLikeToItem(video, "video") == 0)
            {
                throw new Exception($"cannot like photo {task.postUrl}");
            }
        }
Exemplo n.º 3
0
        private void HandlePhotoLikeTask(BotLikeTask task)
        {
            AttachmentPhoto photo = new AttachmentPhoto
            {
                OwnerId = task.ownerId,
                Id      = task.postId
            };

            if (_vkClient.AddLikeToItem(photo, "photo") == 0)
            {
                throw new Exception($"cannot like photo {task.postUrl}");
            }
        }
Exemplo n.º 4
0
        private void HandlePostLikeTask(BotLikeTask task)
        {
            WallPost post = _vkClient.GetPostById($"{task.ownerId}_{task.postId}");

            /*if(post.Reposts.UserReposted)
             *  throw new Exception($"post {task.postUrl} already reposted");*/

            if (post.Likes.CanLike)
            {
                if (_vkClient.AddLikeToItem(post, "post") == 0)
                {
                    throw new Exception($"cannot like post {task.postUrl}");
                }
            }

            if (task.repost == "1" && !post.Reposts.UserReposted)
            {
                if (!_vkClient.Repost(post))
                {
                    throw new Exception($"cannot repost post {task.postUrl}");
                }
            }
        }