예제 #1
0
        public static async Task <string> HandleUrls(string content)
        {
            MatchCollection matches = Url_Regex.Matches(content);

            foreach (Match match in matches)
            {
                bool bypass = false;

                foreach (string s in Media_Bypass)
                {
                    if (match.Value.ToLower().Replace("www.", "").StartsWith(s))
                    {
                        bypass  = true;
                        content = content.Replace(match.Value, $"![]({match.Value})");
                        break;
                    }
                }

                if (!bypass)
                {
                    MSPResponse proxied = await GetProxy(match.Value);

                    if (proxied.Is_Media)
                    {
                        content = content.Replace(match.Value, $"![]({proxied.Url})");
                    }
                }
            }

            return(content);
        }
예제 #2
0
        public static async Task <MSPResponse> GetProxy(string url)
        {
            string encoded_url = HttpUtility.UrlEncode(url);

            var response = await Http.GetAsync($"{MSP_PROXY}?auth={MSPConfig.Current.Api_Key}&url={encoded_url}");

            MSPResponse data = JsonConvert.DeserializeObject <MSPResponse>(await response.Content.ReadAsStringAsync());

            return(data);
        }