Пример #1
0
        public static void Initialize()
        {
            LazyImage.RegisterSpecialResolverTable("pixiv", uri =>
            {
                try
                {
                    var builder = new UriBuilder(uri)
                    {
                        Scheme = "http"
                    };
                    uri = builder.Uri;
                    using (var wc = new WebClientEx())
                    {
                        wc.CookieContainer = new CookieContainer();

                        var src   = wc.DownloadString(uri);
                        var match = PixivRegex.Match(src);
                        if (match.Success)
                        {
                            wc.Referer = uri.OriginalString;
                            return(wc.DownloadData(match.Groups[1].Value));
                        }
                    }
                }
                catch (Exception)
                {
                }
                return(new byte[0]);
            });
        }
Пример #2
0
        private static Completion EmojiCompletion(string emoji, LazyImage emojiImage)
        {
            // Map a completion object for each Emoji to the appropriate image
            var formattedEmoji = $":{emoji}:";

            // Build a completion for each Emoji
            return(new Completion(formattedEmoji, formattedEmoji, formattedEmoji, emojiImage?.Image, formattedEmoji));
        }