nsfw error prettified, upped random limits

This commit is contained in:
Kwoth 2016-12-11 00:09:11 +01:00
parent b47d06fa10
commit a92aaed957

View File

@ -51,7 +51,7 @@ namespace NadekoBot.Modules.NSFW
} }
var link = await provider.ConfigureAwait(false); var link = await provider.ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(link)) if (string.IsNullOrWhiteSpace(link))
await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false); await channel.SendErrorAsync("No results found.").ConfigureAwait(false);
else else
await channel.SendMessageAsync(link).ConfigureAwait(false); await channel.SendMessageAsync(link).ConfigureAwait(false);
} }
@ -68,17 +68,17 @@ namespace NadekoBot.Modules.NSFW
var links = await Task.WhenAll(GetGelbooruImageLink(tag), var links = await Task.WhenAll(GetGelbooruImageLink(tag),
GetDanbooruImageLink(tag), GetDanbooruImageLink(tag),
GetKonachanImageLink(tag), GetKonachanImageLink(tag),
GetYandereImageLink(tag)).ConfigureAwait(false); GetYandereImageLink(tag)).ConfigureAwait(false);
if (links.All(l => l == null)) if (links.All(l => l == null))
{ {
await channel.SendMessageAsync("`No results.`").ConfigureAwait(false); await channel.SendErrorAsync("No results found.").ConfigureAwait(false);
return; return;
} }
await channel.SendMessageAsync(String.Join("\n\n", links)).ConfigureAwait(false); await channel.SendMessageAsync(String.Join("\n\n", links)).ConfigureAwait(false);
} }
public static async Task<string> GetYandereImageLink(string tag) public static async Task<string> GetYandereImageLink(string tag)
{ {
var rng = new NadekoRandom(); var rng = new NadekoRandom();
@ -97,7 +97,7 @@ namespace NadekoBot.Modules.NSFW
return matches[rng.Next(0, matches.Count)].Groups["url"].Value; return matches[rng.Next(0, matches.Count)].Groups["url"].Value;
} }
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Yandere(IUserMessage umsg, [Remainder] string tag = null) public async Task Yandere(IUserMessage umsg, [Remainder] string tag = null)
@ -107,7 +107,7 @@ namespace NadekoBot.Modules.NSFW
tag = tag?.Trim() ?? ""; tag = tag?.Trim() ?? "";
var link = await GetYandereImageLink(tag).ConfigureAwait(false); var link = await GetYandereImageLink(tag).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(link)) if (string.IsNullOrWhiteSpace(link))
await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false); await channel.SendErrorAsync("No results found.").ConfigureAwait(false);
else else
await channel.SendMessageAsync(link).ConfigureAwait(false); await channel.SendMessageAsync(link).ConfigureAwait(false);
} }
@ -121,7 +121,7 @@ namespace NadekoBot.Modules.NSFW
tag = tag?.Trim() ?? ""; tag = tag?.Trim() ?? "";
var link = await GetDanbooruImageLink(tag).ConfigureAwait(false); var link = await GetDanbooruImageLink(tag).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(link)) if (string.IsNullOrWhiteSpace(link))
await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false); await channel.SendErrorAsync("No results found.").ConfigureAwait(false);
else else
await channel.SendMessageAsync(link).ConfigureAwait(false); await channel.SendMessageAsync(link).ConfigureAwait(false);
} }
@ -135,7 +135,7 @@ namespace NadekoBot.Modules.NSFW
tag = tag?.Trim() ?? ""; tag = tag?.Trim() ?? "";
var link = await GetKonachanImageLink(tag).ConfigureAwait(false); var link = await GetKonachanImageLink(tag).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(link)) if (string.IsNullOrWhiteSpace(link))
await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false); await channel.SendErrorAsync("No results found.").ConfigureAwait(false);
else else
await channel.SendMessageAsync(link).ConfigureAwait(false); await channel.SendMessageAsync(link).ConfigureAwait(false);
} }
@ -149,7 +149,7 @@ namespace NadekoBot.Modules.NSFW
tag = tag?.Trim() ?? ""; tag = tag?.Trim() ?? "";
var link = await GetGelbooruImageLink(tag).ConfigureAwait(false); var link = await GetGelbooruImageLink(tag).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(link)) if (string.IsNullOrWhiteSpace(link))
await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false); await channel.SendErrorAsync("No results found.").ConfigureAwait(false);
else else
await channel.SendMessageAsync(link).ConfigureAwait(false); await channel.SendMessageAsync(link).ConfigureAwait(false);
} }
@ -163,7 +163,7 @@ namespace NadekoBot.Modules.NSFW
tag = tag?.Trim() ?? ""; tag = tag?.Trim() ?? "";
var link = await GetRule34ImageLink(tag).ConfigureAwait(false); var link = await GetRule34ImageLink(tag).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(link)) if (string.IsNullOrWhiteSpace(link))
await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false); await channel.SendErrorAsync("No results found.").ConfigureAwait(false);
else else
await channel.SendMessageAsync(link).ConfigureAwait(false); await channel.SendMessageAsync(link).ConfigureAwait(false);
} }
@ -177,7 +177,7 @@ namespace NadekoBot.Modules.NSFW
tag = tag?.Trim() ?? ""; tag = tag?.Trim() ?? "";
var link = await GetE621ImageLink(tag).ConfigureAwait(false); var link = await GetE621ImageLink(tag).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(link)) if (string.IsNullOrWhiteSpace(link))
await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false); await channel.SendErrorAsync("No results found.").ConfigureAwait(false);
else else
await channel.SendMessageAsync(link).ConfigureAwait(false); await channel.SendMessageAsync(link).ConfigureAwait(false);
} }
@ -201,13 +201,13 @@ namespace NadekoBot.Modules.NSFW
JToken obj; JToken obj;
using (var http = new HttpClient()) using (var http = new HttpClient())
{ {
obj = JArray.Parse(await http.GetStringAsync($"http://api.oboobs.ru/boobs/{ new NadekoRandom().Next(0, 9880) }").ConfigureAwait(false))[0]; obj = JArray.Parse(await http.GetStringAsync($"http://api.oboobs.ru/boobs/{ new NadekoRandom().Next(0, 10229) }").ConfigureAwait(false))[0];
} }
await channel.SendMessageAsync($"http://media.oboobs.ru/{ obj["preview"].ToString() }").ConfigureAwait(false); await channel.SendMessageAsync($"http://media.oboobs.ru/{ obj["preview"].ToString() }").ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
await channel.SendMessageAsync($"💢 {ex.Message}").ConfigureAwait(false); await channel.SendErrorAsync(ex.Message).ConfigureAwait(false);
} }
} }
@ -222,13 +222,13 @@ namespace NadekoBot.Modules.NSFW
JToken obj; JToken obj;
using (var http = new HttpClient()) using (var http = new HttpClient())
{ {
obj = JArray.Parse(await http.GetStringAsync($"http://api.obutts.ru/butts/{ new NadekoRandom().Next(0, 3873) }").ConfigureAwait(false))[0]; obj = JArray.Parse(await http.GetStringAsync($"http://api.obutts.ru/butts/{ new NadekoRandom().Next(0, 4222) }").ConfigureAwait(false))[0];
} }
await channel.SendMessageAsync($"http://media.obutts.ru/{ obj["preview"].ToString() }").ConfigureAwait(false); await channel.SendMessageAsync($"http://media.obutts.ru/{ obj["preview"].ToString() }").ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
await channel.SendMessageAsync($"💢 {ex.Message}").ConfigureAwait(false); await channel.SendErrorAsync(ex.Message).ConfigureAwait(false);
} }
} }