From 771bd99d169d2fb6298384685af05f6b479189eb Mon Sep 17 00:00:00 2001 From: abuZayed15 Date: Wed, 7 Oct 2020 23:17:43 -0400 Subject: [PATCH] added Kanye Quote console feature --- Models/KanyeQuoteModel.cs | 13 +++++++++++++ Utilities/KanyeQuote.cs | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 Models/KanyeQuoteModel.cs create mode 100644 Utilities/KanyeQuote.cs diff --git a/Models/KanyeQuoteModel.cs b/Models/KanyeQuoteModel.cs new file mode 100644 index 0000000..5e90d31 --- /dev/null +++ b/Models/KanyeQuoteModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json.Serialization; + +namespace UtilityBelt.Models +{ + public class KanyeQuoteModel + { + [JsonPropertyName("quote")] + public string Quote { get; set; } + } +} diff --git a/Utilities/KanyeQuote.cs b/Utilities/KanyeQuote.cs new file mode 100644 index 0000000..2551134 --- /dev/null +++ b/Utilities/KanyeQuote.cs @@ -0,0 +1,37 @@ +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Composition; +using System.Net; +using System.Text; +using System.Text.Json; +using UtilityBelt.Models; + +namespace UtilityBelt.Utilities +{ + [Export(typeof(IUtility))] + internal class KanyeQuote : IUtility + { + public IList Commands => new List { "kanye", "kanye quote" }; + + public string Name => "Kanye Quote"; + + public void Configure(IOptions options) + { + } + + public void Run() + { + string content = string.Empty; + string kanyeQuoteUrl = @"https://api.kanye.rest/"; + using (var wc = new WebClient()) + { + content = wc.DownloadString(kanyeQuoteUrl); + } + KanyeQuoteModel kanyeQuote = JsonSerializer.Deserialize(content); + Console.WriteLine($"\n{kanyeQuote.Quote}"); + Console.WriteLine(); + } + + } +}