update stuff
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SysEx.Net
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
||||
104
SysEx.Net/Client.cs
Normal file
104
SysEx.Net/Client.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace SysEx.Net
|
||||
{
|
||||
public class SysExClient
|
||||
{
|
||||
readonly Random random;
|
||||
|
||||
public SysExClient()
|
||||
{
|
||||
random = new Random();
|
||||
}
|
||||
|
||||
public async Task<string> GetLlamaAsync() =>
|
||||
await GetAnimalAsync(new Uri("https://api.systemexit.co.uk/get/llama.json"));
|
||||
|
||||
public async Task<string> GetSealAsync() =>
|
||||
await GetAnimalAsync(new Uri("https://api.systemexit.co.uk/get/seal.json"));
|
||||
|
||||
public async Task<string> GetDuckAsync() =>
|
||||
await GetAnimalAsync(new Uri("https://api.systemexit.co.uk/get/duck.json"));
|
||||
|
||||
public async Task<string> GetSquirrelAsync() =>
|
||||
await GetAnimalAsync(new Uri("https://api.systemexit.co.uk/get/squirrel.json"));
|
||||
|
||||
public async Task<string> GetLizardAsync() =>
|
||||
await GetAnimalAsync(new Uri("https://api.systemexit.co.uk/get/lizard.json"));
|
||||
|
||||
public async Task<string> GetMorphAsync() =>
|
||||
await GetAnimalAsync(new Uri("https://api.systemexit.co.uk/get/morphs.json"));
|
||||
|
||||
public async Task<string> GetSnakeAsync() =>
|
||||
await GetAnimalAsync(new Uri("https://api.systemexit.co.uk/get/snake.json"));
|
||||
|
||||
async Task<string> GetAnimalAsync(Uri url)
|
||||
{
|
||||
var resp = await WebRequest.ReturnStringAsync(url);
|
||||
var items = JsonConvert.DeserializeObject<List<Animal>>(resp);
|
||||
if (items == null) return null;
|
||||
var animal = items[random.Next(0, items.Count)].URL;
|
||||
return animal;
|
||||
}
|
||||
|
||||
public async Task<string> GetRoastAsync()
|
||||
{
|
||||
var resp = await WebRequest.ReturnStringAsync(new Uri("https://api.systemexit.co.uk/get/roasts.json"));
|
||||
var items = JsonConvert.DeserializeObject<List<Roasts>>(resp);
|
||||
if (items == null) return null;
|
||||
return items[random.Next(0, items.Count)].Roast;
|
||||
}
|
||||
|
||||
public async Task<Joke> GetDadJokeAsync()
|
||||
{
|
||||
var resp = await WebRequest.ReturnStringAsync(new Uri("https://api.systemexit.co.uk/get/dadjokes.json"));
|
||||
var items = JsonConvert.DeserializeObject<List<Joke>>(resp);
|
||||
if (items == null) return null;
|
||||
return items[random.Next(0, items.Count)];
|
||||
}
|
||||
|
||||
public async Task<Joke> GetPickupLineAsync()
|
||||
{
|
||||
var resp = await WebRequest.ReturnStringAsync(new Uri("https://api.systemexit.co.uk/get/pickuplines.json"));
|
||||
var items = JsonConvert.DeserializeObject<List<Joke>>(resp);
|
||||
if (items == null) return null;
|
||||
return items[random.Next(0, items.Count)];
|
||||
}
|
||||
|
||||
public async Task<WeebGif> GetWeebActionGifAsync(GifType type)
|
||||
{
|
||||
var resp = await WebRequest.ReturnStringAsync(new Uri("https://api.systemexit.co.uk/get/actions/type/" + type + ".json"));
|
||||
var items = JsonConvert.DeserializeObject<IReadOnlyList<WeebGif>>(resp);
|
||||
return items[random.Next(0, items.Count)];
|
||||
}
|
||||
|
||||
public async Task<WeebGif> GetWeebReactionGifAsync()
|
||||
{
|
||||
var resp = await WebRequest.ReturnStringAsync(new Uri("https://api.systemexit.co.uk/get/reactions.json"));
|
||||
var items = JsonConvert.DeserializeObject<List<WeebGif>>(resp);
|
||||
if (items == null) return null;
|
||||
return items[random.Next(0, items.Count)];
|
||||
}
|
||||
|
||||
public async Task<string> GetLewdKitsuneAsync()
|
||||
{
|
||||
var rawresp = await WebRequest.ReturnStringAsync(new Uri("https://kitsu.systemexit.co.uk/lewd"));
|
||||
dynamic item = JObject.Parse(rawresp);
|
||||
var img = item["kitsune"];
|
||||
if (img == null) return null;
|
||||
return img;
|
||||
}
|
||||
public async Task<string> GetKitsuneAsync()
|
||||
{
|
||||
var rawresp = await WebRequest.ReturnStringAsync(new Uri("https://kitsu.systemexit.co.uk/kitsune"));
|
||||
dynamic item = JObject.Parse(rawresp);
|
||||
var img = item["kitsune"];
|
||||
if (img == null) return null;
|
||||
return img;
|
||||
}
|
||||
}
|
||||
}
|
||||
10
SysEx.Net/Models/Animal.cs
Normal file
10
SysEx.Net/Models/Animal.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace SysEx.Net
|
||||
{
|
||||
public class Animal
|
||||
{
|
||||
[JsonProperty(PropertyName = "file")]
|
||||
public string URL { get; set; }
|
||||
}
|
||||
}
|
||||
8
SysEx.Net/Models/PickupLine.cs
Normal file
8
SysEx.Net/Models/PickupLine.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace SysEx.Net
|
||||
{
|
||||
public class Joke
|
||||
{
|
||||
public string Setup { get; set; }
|
||||
public string Punchline { get; set; }
|
||||
}
|
||||
}
|
||||
7
SysEx.Net/Models/Roast.cs
Normal file
7
SysEx.Net/Models/Roast.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace SysEx.Net
|
||||
{
|
||||
public class Roasts
|
||||
{
|
||||
public string Roast { get; set; }
|
||||
}
|
||||
}
|
||||
48
SysEx.Net/Models/WeebGif.cs
Normal file
48
SysEx.Net/Models/WeebGif.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
namespace SysEx.Net
|
||||
{
|
||||
public class WeebGif
|
||||
{
|
||||
[JsonProperty(PropertyName = "url")]
|
||||
public string URL { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "type")]
|
||||
public GifType GifType { get; set; }
|
||||
}
|
||||
public enum GifType
|
||||
{
|
||||
Adore,
|
||||
Amazed,
|
||||
Approve,
|
||||
Blush,
|
||||
Bored,
|
||||
Cuddle,
|
||||
Dance,
|
||||
Disgust,
|
||||
Disapprove,
|
||||
Feels,
|
||||
Glare,
|
||||
Grope,
|
||||
Happy,
|
||||
Hug,
|
||||
Kill,
|
||||
Kiss,
|
||||
Lewd,
|
||||
Mad,
|
||||
Moe,
|
||||
Nani,
|
||||
Nope,
|
||||
Pet,
|
||||
Punch,
|
||||
Sad,
|
||||
Shock,
|
||||
Shrug,
|
||||
Slap,
|
||||
Smug,
|
||||
Stab,
|
||||
Triggered,
|
||||
Unamused
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,25 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>exsersewo</Authors>
|
||||
<Company />
|
||||
<PackageProjectUrl>https://github.com/exsersewo/SysEx.Net</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/exsersewo/SysEx.Net</RepositoryUrl>
|
||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
<Description>A .Net Wrapper for utilties hosted at: https://api.systemexit.co.uk/ & https://kitsu.systemexit.co.uk/</Description>
|
||||
<Copyright>exsersewo</Copyright>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<Optimize>true</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.4.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
<PackageReference Include="System.Net.Requests" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
49
SysEx.Net/WebRequest.cs
Normal file
49
SysEx.Net/WebRequest.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
namespace SysEx.Net
|
||||
{
|
||||
class WebRequest
|
||||
{
|
||||
public static HttpWebRequest CreateWebRequest(Uri uri)
|
||||
{
|
||||
var cli = (HttpWebRequest)System.Net.WebRequest.Create(uri);
|
||||
|
||||
cli.AllowAutoRedirect = true;
|
||||
cli.KeepAlive = false;
|
||||
cli.Timeout = 20000;
|
||||
cli.ProtocolVersion = HttpVersion.Version10;
|
||||
|
||||
return cli;
|
||||
}
|
||||
public static async Task<string> ReturnStringAsync(Uri url)
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = CreateWebRequest(url);
|
||||
|
||||
var resp = (HttpWebResponse)(await client.GetResponseAsync());
|
||||
if (resp.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
var reader = new StreamReader(resp.GetResponseStream());
|
||||
var responce = await reader.ReadToEndAsync();
|
||||
resp.Dispose();
|
||||
client.Abort();
|
||||
return responce;
|
||||
}
|
||||
else
|
||||
{
|
||||
resp.Dispose();
|
||||
client.Abort();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user