Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Kanye Quote console feature #69

Merged
merged 1 commit into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Models/KanyeQuoteModel.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
37 changes: 37 additions & 0 deletions Utilities/KanyeQuote.cs
Original file line number Diff line number Diff line change
@@ -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<string> Commands => new List<string> { "kanye", "kanye quote" };

public string Name => "Kanye Quote";

public void Configure(IOptions<SecretsModel> 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<KanyeQuoteModel>(content);
Console.WriteLine($"\n{kanyeQuote.Quote}");
Console.WriteLine();
}

}
}