~atf added
This commit is contained in:
parent
17e6fc909b
commit
5c20c88253
@ -41,6 +41,20 @@ namespace NadekoBot.Modules.NSFW
|
||||
await channel.SendMessageAsync(String.Join("\n\n", links)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ATFbooru(IUserMessage umsg, [Remainder] string tag = null)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
tag = tag?.Trim() ?? "";
|
||||
var link = await GetATFbooruImageLink(tag).ConfigureAwait(false);
|
||||
if (string.IsNullOrWhiteSpace(link))
|
||||
await channel.SendMessageAsync("Search yielded no results ;(");
|
||||
else
|
||||
await channel.SendMessageAsync(link).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Danbooru(IUserMessage umsg, [Remainder] string tag = null)
|
||||
@ -255,5 +269,25 @@ namespace NadekoBot.Modules.NSFW
|
||||
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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2114,6 +2114,15 @@
|
||||
</data>
|
||||
<data name="danbooru_usage" xml:space="preserve">
|
||||
<value>`{0}danbooru yuri+kissing`</value>
|
||||
</data>
|
||||
<data name="atfbooru_cmd" xml:space="preserve">
|
||||
<value>atfbooru atf</value>
|
||||
</data>
|
||||
<data name="atfbooru_desc" xml:space="preserve">
|
||||
<value>Shows a random hentai image from atfbooru with a given tag. Tag is optional but preferred.</value>
|
||||
</data>
|
||||
<data name="atfbooru_usage" xml:space="preserve">
|
||||
<value>`{0}atfbooru yuri+kissing`</value>
|
||||
</data>
|
||||
<data name="gelbooru_cmd" xml:space="preserve">
|
||||
<value>gelbooru</value>
|
||||
|
Loading…
Reference in New Issue
Block a user