Tweak and update api urls
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -259,3 +259,4 @@ paket-files/
|
|||||||
# Python Tools for Visual Studio (PTVS)
|
# Python Tools for Visual Studio (PTVS)
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
|
/SysEx.Net/Properties/PublishProfiles/FolderProfile.pubxml
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace SysEx.Net
|
|||||||
public class SysExClient
|
public class SysExClient
|
||||||
{
|
{
|
||||||
readonly Random random;
|
readonly Random random;
|
||||||
|
readonly Uri APIBase = new Uri("https://api.exsersewo.dev");
|
||||||
|
readonly Uri KitsuBase = new Uri("https://kitsu.exsersewo.dev");
|
||||||
|
|
||||||
public SysExClient()
|
public SysExClient()
|
||||||
{
|
{
|
||||||
@@ -22,43 +24,43 @@ namespace SysEx.Net
|
|||||||
/// Gets a Llama image
|
/// Gets a Llama image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<string> GetLlamaAsync() =>
|
public async Task<string> GetLlamaAsync() =>
|
||||||
await GetAnimalAsync(new Uri("https://api.systemexit.co.uk/v1/llama.json"));
|
await GetAnimalAsync(new Uri(APIBase, "/v1/llama.json"));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a Seal image
|
/// Gets a Seal image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<string> GetSealAsync() =>
|
public async Task<string> GetSealAsync() =>
|
||||||
await GetAnimalAsync(new Uri("https://api.systemexit.co.uk/v1/seal.json"));
|
await GetAnimalAsync(new Uri(APIBase, "/v1/seal.json"));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a Duck image
|
/// Gets a Duck image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<string> GetDuckAsync() =>
|
public async Task<string> GetDuckAsync() =>
|
||||||
await GetAnimalAsync(new Uri("https://api.systemexit.co.uk/v1/duck.json"));
|
await GetAnimalAsync(new Uri(APIBase, "/v1/duck.json"));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a Squirrel image
|
/// Gets a Squirrel image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<string> GetSquirrelAsync() =>
|
public async Task<string> GetSquirrelAsync() =>
|
||||||
await GetAnimalAsync(new Uri("https://api.systemexit.co.uk/v1/squirrel.json"));
|
await GetAnimalAsync(new Uri(APIBase, "/v1/squirrel.json"));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a Lizard image
|
/// Gets a Lizard image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<string> GetLizardAsync() =>
|
public async Task<string> GetLizardAsync() =>
|
||||||
await GetAnimalAsync(new Uri("https://api.systemexit.co.uk/v1/lizard.json"));
|
await GetAnimalAsync(new Uri(APIBase, "/v1/lizard.json"));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a morphed animal image
|
/// Gets a morphed animal image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<string> GetMorphAsync() =>
|
public async Task<string> GetMorphAsync() =>
|
||||||
await GetAnimalAsync(new Uri("https://api.systemexit.co.uk/v1/morphs.json"));
|
await GetAnimalAsync(new Uri(APIBase, "/v1/morphs.json"));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a Snake image
|
/// Gets a Snake image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<string> GetSnakeAsync() =>
|
public async Task<string> GetSnakeAsync() =>
|
||||||
await GetAnimalAsync(new Uri("https://api.systemexit.co.uk/v1/snake.json"));
|
await GetAnimalAsync(new Uri(APIBase, "/v1/snake.json"));
|
||||||
|
|
||||||
async Task<string> GetAnimalAsync(Uri url)
|
async Task<string> GetAnimalAsync(Uri url)
|
||||||
{
|
{
|
||||||
@@ -74,7 +76,7 @@ namespace SysEx.Net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<string> GetRoastAsync()
|
public async Task<string> GetRoastAsync()
|
||||||
{
|
{
|
||||||
var resp = await WebRequest.ReturnStringAsync(new Uri("https://api.systemexit.co.uk/v1/roasts.json"));
|
var resp = await WebRequest.ReturnStringAsync(new Uri(APIBase, "/v1/roasts.json"));
|
||||||
var items = JsonConvert.DeserializeObject<List<Roasts>>(resp);
|
var items = JsonConvert.DeserializeObject<List<Roasts>>(resp);
|
||||||
if (items == null) return null;
|
if (items == null) return null;
|
||||||
return items[random.Next(0, items.Count)].Roast;
|
return items[random.Next(0, items.Count)].Roast;
|
||||||
@@ -85,7 +87,7 @@ namespace SysEx.Net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<Joke> GetDadJokeAsync()
|
public async Task<Joke> GetDadJokeAsync()
|
||||||
{
|
{
|
||||||
var resp = await WebRequest.ReturnStringAsync(new Uri("https://api.systemexit.co.uk/v1/dadjokes.json"));
|
var resp = await WebRequest.ReturnStringAsync(new Uri(APIBase, "/v1/dadjokes.json"));
|
||||||
var items = JsonConvert.DeserializeObject<List<Joke>>(resp);
|
var items = JsonConvert.DeserializeObject<List<Joke>>(resp);
|
||||||
if (items == null) return null;
|
if (items == null) return null;
|
||||||
return items[random.Next(0, items.Count)];
|
return items[random.Next(0, items.Count)];
|
||||||
@@ -96,33 +98,13 @@ namespace SysEx.Net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<Joke> GetPickupLineAsync()
|
public async Task<Joke> GetPickupLineAsync()
|
||||||
{
|
{
|
||||||
var resp = await WebRequest.ReturnStringAsync(new Uri("https://api.systemexit.co.uk/v1/pickuplines.json"));
|
var resp = await WebRequest.ReturnStringAsync(new Uri(APIBase, "/v1/pickuplines.json"));
|
||||||
var items = JsonConvert.DeserializeObject<List<Joke>>(resp);
|
var items = JsonConvert.DeserializeObject<List<Joke>>(resp);
|
||||||
if (items == null) return null;
|
if (items == null) return null;
|
||||||
return items[random.Next(0, items.Count)];
|
return items[random.Next(0, items.Count)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private Uri MemeAPIBase = new Uri("https://api.skuldbot.uk/meme/");
|
||||||
/// Gets A Weeb Action Gif
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="type">Gif Action Type</param>
|
|
||||||
/// <returns>Url of image</returns>
|
|
||||||
public async Task<string> GetWeebActionGifAsync(GifType type)
|
|
||||||
{
|
|
||||||
var resp = await WebRequest.GetRedirectUriAsync(new Uri("https://api.systemexit.co.uk/actions/?action=" + type.ToString().ToLowerInvariant()));
|
|
||||||
return resp.OriginalString;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets A Weeb Reaction Gif
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Url of image</returns>
|
|
||||||
public async Task<string> GetWeebReactionGifAsync()
|
|
||||||
{
|
|
||||||
var resp = await WebRequest.ReturnStringAsync(new Uri("https://api.systemexit.co.uk/reactions/"));
|
|
||||||
return resp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a meme image based on given input
|
/// Gets a meme image based on given input
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -131,14 +113,11 @@ namespace SysEx.Net
|
|||||||
/// <returns>Either Object. MemeResponse on empty input or failure, or MemoryStream on success</returns>
|
/// <returns>Either Object. MemeResponse on empty input or failure, or MemoryStream on success</returns>
|
||||||
public async Task<object> GetMemeImageAsync(string template = null, params string[] images)
|
public async Task<object> GetMemeImageAsync(string template = null, params string[] images)
|
||||||
{
|
{
|
||||||
var endpoints = JsonConvert.DeserializeObject<MemeResponse>(await WebRequest.ReturnStringAsync(new Uri("https://api.skuldbot.uk/fun/meme/?endpoints")));
|
|
||||||
if (template == null && (images.Length <= 0 || images == null))
|
if (template == null && (images.Length <= 0 || images == null))
|
||||||
{
|
{
|
||||||
return endpoints;
|
return JsonConvert.DeserializeObject<MemeResponse>(await WebRequest.ReturnStringAsync(MemeAPIBase));
|
||||||
}
|
}
|
||||||
if(endpoints.Endpoints.Exists(x=>x.Name.ToLowerInvariant() == template.ToLowerInvariant()))
|
|
||||||
{
|
|
||||||
var endpoint = endpoints.Endpoints.FirstOrDefault(z => z.Name.ToLowerInvariant() == template.ToLowerInvariant());
|
|
||||||
string queryString = "";
|
string queryString = "";
|
||||||
int x = 1;
|
int x = 1;
|
||||||
foreach(var image in images)
|
foreach(var image in images)
|
||||||
@@ -154,17 +133,18 @@ namespace SysEx.Net
|
|||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
|
|
||||||
var resp = await WebRequest.GetStreamAsync(new Uri($"https://api.skuldbot.uk/fun/meme/{template}/?{queryString}"));
|
var templateURL = new Uri(MemeAPIBase, $"template/{template}/?{queryString}");
|
||||||
|
|
||||||
|
var resp = await WebRequest.GetStreamAsync(templateURL);
|
||||||
if(resp != null)
|
if(resp != null)
|
||||||
{
|
{
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
return new MemeResponse
|
|
||||||
{
|
{
|
||||||
Successful = false,
|
dynamic reason = JsonConvert.DeserializeObject(await WebRequest.ReturnStringAsync(templateURL));
|
||||||
Endpoints = endpoints.Endpoints
|
throw new Exception(reason["reason"]);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -172,7 +152,7 @@ namespace SysEx.Net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<string> GetLewdKitsuneAsync()
|
public async Task<string> GetLewdKitsuneAsync()
|
||||||
{
|
{
|
||||||
var rawresp = await WebRequest.ReturnStringAsync(new Uri("https://kitsu.systemexit.co.uk/lewd"));
|
var rawresp = await WebRequest.ReturnStringAsync(new Uri(KitsuBase, "/lewd"));
|
||||||
dynamic item = JObject.Parse(rawresp);
|
dynamic item = JObject.Parse(rawresp);
|
||||||
var img = item["kitsune"];
|
var img = item["kitsune"];
|
||||||
if (img == null) return null;
|
if (img == null) return null;
|
||||||
@@ -183,7 +163,7 @@ namespace SysEx.Net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<string> GetKitsuneAsync()
|
public async Task<string> GetKitsuneAsync()
|
||||||
{
|
{
|
||||||
var rawresp = await WebRequest.ReturnStringAsync(new Uri("https://kitsu.systemexit.co.uk/kitsune"));
|
var rawresp = await WebRequest.ReturnStringAsync(new Uri(KitsuBase, "/kitsune"));
|
||||||
dynamic item = JObject.Parse(rawresp);
|
dynamic item = JObject.Parse(rawresp);
|
||||||
var img = item["kitsune"];
|
var img = item["kitsune"];
|
||||||
if (img == null) return null;
|
if (img == null) return null;
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ namespace SysEx.Net.Models
|
|||||||
{
|
{
|
||||||
public struct MemeEndpoints
|
public struct MemeEndpoints
|
||||||
{
|
{
|
||||||
[JsonProperty("Name")]
|
[JsonProperty("endpoint")]
|
||||||
public string Name;
|
public string Name;
|
||||||
[JsonProperty("RequiredSources")]
|
[JsonProperty("sources")]
|
||||||
public int RequiredSources;
|
public int RequiredSources;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,10 @@ namespace SysEx.Net.Models
|
|||||||
{
|
{
|
||||||
public struct MemeResponse
|
public struct MemeResponse
|
||||||
{
|
{
|
||||||
[JsonProperty("Successful")]
|
[JsonProperty("success")]
|
||||||
public bool Successful;
|
public bool Successful;
|
||||||
[JsonProperty("example")]
|
|
||||||
public string Example;
|
|
||||||
|
|
||||||
[JsonProperty("available-templates")]
|
[JsonProperty("data")]
|
||||||
public List<MemeEndpoints> Endpoints;
|
public List<MemeEndpoints> Endpoints;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,15 @@
|
|||||||
<RepositoryUrl>https://github.com/exsersewo/SysEx.Net</RepositoryUrl>
|
<RepositoryUrl>https://github.com/exsersewo/SysEx.Net</RepositoryUrl>
|
||||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||||
<SignAssembly>false</SignAssembly>
|
<SignAssembly>false</SignAssembly>
|
||||||
<Description>A .Net Wrapper for utilties hosted at: https://api.systemexit.co.uk/ & https://kitsu.systemexit.co.uk/</Description>
|
<Description>A .Net Wrapper for utilties hosted at: https://api.exsersewo.dev/ & https://kitsu.exsersewo.dev/ & https://api.skuldbot.uk/meme</Description>
|
||||||
<Copyright>exsersewo</Copyright>
|
<Copyright>exsersewo</Copyright>
|
||||||
<PackageReleaseNotes>Initial Release</PackageReleaseNotes>
|
<PackageReleaseNotes>Initial Release</PackageReleaseNotes>
|
||||||
<NeutralLanguage>en-GB</NeutralLanguage>
|
<NeutralLanguage>en-GB</NeutralLanguage>
|
||||||
<RepositoryType>Library</RepositoryType>
|
<RepositoryType>Library</RepositoryType>
|
||||||
<PackageLicenseUrl>https://github.com/exsersewo/SysEx.Net/blob/master/LICENSE</PackageLicenseUrl>
|
<PackageLicenseUrl>https://github.com/exsersewo/SysEx.Net/blob/master/LICENSE</PackageLicenseUrl>
|
||||||
<Version>1.0.7</Version>
|
<Version>1.0.9</Version>
|
||||||
|
<AssemblyVersion>1.0.9.0</AssemblyVersion>
|
||||||
|
<FileVersion>1.0.9.0</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
Reference in New Issue
Block a user