示例#1
0
        public static MessageBuilder CheckStores()
        {
            MessageBuilder mb          = new MessageBuilder();
            string         shop_sprite = ".//resources//tmp_shops.png";
            EmbedBuilder   eb          = Embedder.DefaultEmbed;

            // for each store
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Schematrix [OPEN]");       // The schema shop for profiles
            sb.AppendLine("Pocket Residence [OPEN]"); // Mr. Pocket's home location.

            eb.WithDescription(sb.ToString());
            eb.WithLocalImageUrl(shop_sprite);
            mb.WithFile(shop_sprite);
            mb.WithEmbed(eb);

            return(mb);
        }
示例#2
0
        public MessageStructure ToMessage(IconFormat f)
        {
            MessageBuilder mb = new MessageBuilder();
            EmbedBuilder   eb = Embedder.DefaultEmbed;

            StringBuilder title = new StringBuilder();

            title.AppendLine(Source.Author.Name.MarkdownBold());

            if (Source.Recipients.Funct())
            {
                if (Source.Recipients.Count > 1)
                {
                    title.AppendLine($"**Recipients**: {string.Join(",", Source.Recipients.Select(x => $"{x.Id}".DiscordLine()))}");
                }
            }

            if (Source.IsThreaded)
            {
                title.AppendLine($"**Thread**: {Source.Thread.Root.Subject}\n**SubThread**: {Source.Subject}");
            }
            else
            {
                title.AppendLine($"**Subject**: {Source.Subject}");
            }
            if (Source.Locked)
            {
                title.Insert(0, EmojiIndex.Locked.Format(AccountOptions.Default.IconFormat) + " ");
            }
            if (Source.Marked)
            {
                eb.WithColor(EmbedData.GetColor("error"));
            }
            else if (!Source.Read)
            {
                eb.WithColor(EmbedData.GetColor("owo"));
            }

            eb.WithTitle(title.ToString());
            if (Source.HasMessage)
            {
                eb.WithDescription(Source.Message);
            }

            eb.WithFooter(Source.Id);
            eb.WithTimestamp(Source.Date);

            if (Source.HasAttachment)
            {
                if (Source.Attachment.IsEmbeddable)
                {
                    eb.WithImageUrl(Source.Attachment.Url);
                    // in the case of the image being unable to load..?
                    string msg = $"Attachment [{Source.Attachment.Type}]".DiscordLine().MarkdownLink(Source.Attachment.Url);
                    eb.WithDescription(eb.Description.Exists() ? $"{eb.Description}\n{msg}" : msg);
                }
                else if (Source.Attachment.IsWritten)
                {
                    var client             = new OriWebClient();
                    WebResponse <string> r = client.RequestAsync <string>(Source.Attachment.Url).ConfigureAwait(false).GetAwaiter().GetResult();
                    if (r.IsSuccess)
                    {
                        "i passed".Debug();
                        string msg = r.Data.Clean(); // 6 = ``` ``` , 2 = \n \n

                        int limit = 256 - Source.Attachment.CodeLanguage.Length - 6 - 2;

                        if (msg.Length > limit)
                        {
                            msg = msg.Substring(0, limit);
                        }

                        string link = $"Attachment [{Source.Attachment.Type}]".DiscordLine().MarkdownLink(Source.Attachment.Url);
                        msg = msg.DiscordBlock(Source.Attachment.CodeLanguage);
                        eb.WithDescription(eb.Description.Exists() ? $"{eb.Description}\n{msg}{link}": msg + link);
                    }
                }
                else
                {
                    string msg = $"Attachment [{Source.Attachment.Type}]".DiscordLine().MarkdownLink(Source.Attachment.Url);
                    eb.WithDescription(eb.Description.Exists() ? $"{eb.Description}\n{msg}" : msg);
                }
            }

            mb.WithEmbed(eb);

            return(mb.Build());
        }