Ejemplo n.º 1
0
        /// <summary>
        /// Pull and post the last updated post on facebook
        /// </summary>
        /// <param name="_discordClient"></param>
        /// <returns></returns>
        public async Task PostLastFacebookPost(DiscordSocketClient _discordClient)
        {
            #region Debug ID's

            /*Facebook feed channel ID
             *  619919379148046356
             */

            /*Test-Chamber Channel ID
             *  615970271827853312
             */
            #endregion

            IMessageChannel channel = await _discordClient.GetFacebookFeedChannel() as IMessageChannel;

            //  Iterrate trough all posts in the feed
            foreach (var post in Instance.Facebook.feed.data)
            {
                //  Check if a post is new
                if (post.GetPostTime().ToLocalTime() > LastPost)
                {
                    //  Set the newest post date
                    LastPost = post.GetPostTime().ToLocalTime();
                    await channel.SendMessageAsync($"**<Post Feed Updated>**{Environment.NewLine}{post.message}{Environment.NewLine}{post.full_picture ?? ""}");

                    //  Only try to collect comments to a post if there is any
                    if (post.comments != null)
                    {
                        //  Loop trough each comment
                        foreach (var comment in post.comments.data)
                        {
                            await channel.SendMessageAsync($"----**Comment:** <{post.id}>{Environment.NewLine}----: _{comment.message}_");

                            //  Only try to collect subComments to a comment if there is any
                            if (comment.comments != null)
                            {
                                //  Loop trough each subComment
                                foreach (var subComment in comment.comments.data)
                                {
                                    await channel.SendMessageAsync($"--------**SubComment**:{Environment.NewLine}--------:_{subComment.message}_");
                                }
                            }
                        }
                    }
                }
            }
        }