From 1ee8875db593570c1f4637d724cff95d3e9046e4 Mon Sep 17 00:00:00 2001 From: Tommy Parnell Date: Sat, 20 Jul 2019 10:53:56 -0400 Subject: [PATCH] unfurl for real --- Main.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Main.cs b/Main.cs index 4f19f08..d00f20d 100644 --- a/Main.cs +++ b/Main.cs @@ -14,6 +14,15 @@ using System.Linq; namespace bundlephobia { + class SlackPost + { + public Dictionary attachments { get; set; } + [JsonProperty("unfurl_links")] + public bool unfurlLinks { get; set; } = true; + [JsonProperty("unfurl_media")] + public bool unfurlMedia { get; set; } = true; + + } public static class Main { static HttpClient Client = new HttpClient(); @@ -41,7 +50,13 @@ namespace bundlephobia var resp = await Client.GetAsync($"https://bundlephobia.com/api/package-history?package={text}"); var respData = JsonConvert.DeserializeObject>(await resp.Content.ReadAsStringAsync()); var version = respData.Keys.OrderByDescending(a => a).First(); - await Client.PostAsJsonAsync(responseUrl, new { text = $"https://bundlephobia.com/result?p={text}@{version}", unfurl_links = true, unfurl_media = true }); + await Client.PostAsJsonAsync(responseUrl, new SlackPost() + { + attachments = new Dictionary() + { + [text] = $"https://bundlephobia.com/result?p={text}@{version}" + } + }); } catch (Exception e) {