示例#1
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}");
                }
            }
        }