コード例 #1
0
        private static string GeneratePostBody(List <Command> commands)
        {
            string template = "";

            foreach (Command r in commands)
            {
                if (r.Type == SearchId || r.Type == SearchName || r.Type == SearchUrl)
                {
                    var root = (StoryData.Story)r.Response;
                    if (root.data.Length == 0)
                    {
                        template += Constants.NoResults;
                        continue;
                    }

                    StoryData.Datum story = root.data.First();
                    if (story.attributes.content_rating == "mature")
                    {
                        template += Constants.NotAllowed;
                    }
                    else
                    {
                        string u = GetAuthorUsername(root);
                        template += "\r\n [](/twibeam) \r\n" +
                                    $"#[{story.attributes.title}]({story.meta.url})\r\n" +
                                    $"*by [{u}](https://www.fimfiction.net/user/{story.relationships.author.data.id}/{u}) " +
                                    $"| {story.attributes.date_published:dd MMM yyyy} " +
                                    $"| {Utils.FormatNumber(story.attributes.total_num_views)} Views" +
                                    $"| {Utils.FormatNumber(story.attributes.num_words)} Words " +
                                    $"| Status: `{Utils.UppercaseFirst(story.attributes.completion_status)}` " +
                                    $"| Rating: {GetRatingString(story)}*\r\n\r\n" +
                                    $"{story.attributes.short_description}" +
                                    "\r\n\r\n" +
                                    $"**Tags**: {GenerateTags(root)}";
                    }

                    template += "[](//sp)" +
                                "\r\n \r\n" +
                                "-----";
                }
            }

            template += Constants.Footer;

            return(template);
        }
コード例 #2
0
 private static string GetRatingString(StoryData.Datum story)
 {
     return(story.attributes.num_likes == -1 && story.attributes.num_dislikes == -1
         ? "`Hidden`"
         : $"`\U0001F44D {story.attributes.num_likes} | \U0001F44E {story.attributes.num_dislikes}`");
 }