removed atf completely, closes #832

This commit is contained in:
Kwoth 2016-12-01 12:33:52 +01:00
parent 140ec95e04
commit d4985f26dd

View File

@ -68,8 +68,7 @@ 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), GetYandereImageLink(tag)).ConfigureAwait(false);
GetATFbooruImageLink(tag)).ConfigureAwait(false);
if (links.All(l => l == null)) if (links.All(l => l == null))
{ {
@ -327,25 +326,5 @@ namespace NadekoBot.Modules.NSFW
return "Error, do you have too many tags?"; return "Error, do you have too many tags?";
} }
} }
public static async Task<string> GetATFbooruImageLink(string tag)
{
var rng = new NadekoRandom();
var link = $"https://atfbooru.ninja/posts?" +
$"limit=100";
if (!string.IsNullOrWhiteSpace(tag))
link += $"&tags={tag.Replace(" ", "+")}";
using (var http = new HttpClient())
{
var webpage = await http.GetStringAsync(link).ConfigureAwait(false);
var matches = Regex.Matches(webpage, "data-file-url=\"(?<id>.*?)\"");
if (matches.Count == 0)
return null;
return $"https://atfbooru.ninja" +
$"{matches[rng.Next(0, matches.Count)].Groups["id"].Value}";
}
}
} }
} }