commit
3e0b56c52d
@ -34,7 +34,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
|
||||
var rng = new NadekoRandom();
|
||||
Task<string> provider = Task.FromResult("");
|
||||
switch (rng.Next(0,4))
|
||||
switch (rng.Next(0,5))
|
||||
{
|
||||
case 0:
|
||||
provider = GetDanbooruImageLink(tag);
|
||||
@ -48,6 +48,9 @@ namespace NadekoBot.Modules.NSFW
|
||||
case 3:
|
||||
provider = GetKonachanImageLink(tag);
|
||||
break;
|
||||
case 4:
|
||||
provider = GetYandereImageLink(tag);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -70,6 +73,7 @@ namespace NadekoBot.Modules.NSFW
|
||||
var links = await Task.WhenAll(GetGelbooruImageLink(tag),
|
||||
GetDanbooruImageLink(tag),
|
||||
GetKonachanImageLink(tag),
|
||||
GetYandereImageLink(tag),
|
||||
GetATFbooruImageLink(tag)).ConfigureAwait(false);
|
||||
|
||||
if (links.All(l => l == null))
|
||||
@ -95,6 +99,39 @@ namespace NadekoBot.Modules.NSFW
|
||||
await channel.SendMessageAsync(link).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public static async Task<string> GetYandereImageLink(string tag)
|
||||
{
|
||||
var rng = new NadekoRandom();
|
||||
var url =
|
||||
$"https://yande.re/post.xml?" +
|
||||
$"limit=25" +
|
||||
$"&page={rng.Next(0, 15)}" +
|
||||
$"&tags={tag.Replace(" ", "_")}";
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
var webpage = await http.GetStringAsync(url).ConfigureAwait(false);
|
||||
var matches = Regex.Matches(webpage, "file_url=\"(?<url>.*?)\"");
|
||||
//var rating = Regex.Matches(webpage, "rating=\"(?<rate>.*?)\"");
|
||||
if (matches.Count == 0)
|
||||
return null;
|
||||
return matches[rng.Next(0, matches.Count)].Groups["url"].Value;
|
||||
}
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Yandere(IUserMessage umsg, [Remainder] string tag = null)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
tag = tag?.Trim() ?? "";
|
||||
var link = await GetYandereImageLink(tag).ConfigureAwait(false);
|
||||
if (string.IsNullOrWhiteSpace(link))
|
||||
await channel.SendMessageAsync("Search yielded no results ;(").ConfigureAwait(false);
|
||||
else
|
||||
await channel.SendMessageAsync(link).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Danbooru(IUserMessage umsg, [Remainder] string tag = null)
|
||||
|
31
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
31
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
@ -2931,7 +2931,7 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Shows a hentai image from a random website (gelbooru or danbooru or konachan or atfbooru) with a given tag. Tag is optional but preferred. Only 1 tag allowed..
|
||||
/// Looks up a localized string similar to Shows a hentai image from a random website (gelbooru or danbooru or konachan or atfbooru or yandere) with a given tag. Tag is optional but preferred. Only 1 tag allowed..
|
||||
/// </summary>
|
||||
public static string hentai_desc {
|
||||
get {
|
||||
@ -2958,7 +2958,7 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Shows a total 4 images (from gelbooru, danbooru, konachan and atfbooru). Tag is optional but preferred..
|
||||
/// Looks up a localized string similar to Shows a total 5 images (from gelbooru, danbooru, konachan, yandere and atfbooru). Tag is optional but preferred..
|
||||
/// </summary>
|
||||
public static string hentaibomb_desc {
|
||||
get {
|
||||
@ -7700,6 +7700,33 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to yandere.
|
||||
/// </summary>
|
||||
public static string yandere_cmd {
|
||||
get {
|
||||
return ResourceManager.GetString("yandere_cmd", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Shows a random image from yandere with a given tag. Tag is optional but preferred. (multiple tags are appended with +).
|
||||
/// </summary>
|
||||
public static string yandere_desc {
|
||||
get {
|
||||
return ResourceManager.GetString("yandere_desc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to `{0}yandere tag1+tag2`.
|
||||
/// </summary>
|
||||
public static string yandere_usage {
|
||||
get {
|
||||
return ResourceManager.GetString("yandere_usage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to yomama ym.
|
||||
/// </summary>
|
||||
|
@ -2110,7 +2110,7 @@
|
||||
<value>hentai</value>
|
||||
</data>
|
||||
<data name="hentai_desc" xml:space="preserve">
|
||||
<value>Shows a hentai image from a random website (gelbooru or danbooru or konachan or atfbooru) with a given tag. Tag is optional but preferred. Only 1 tag allowed.</value>
|
||||
<value>Shows a hentai image from a random website (gelbooru or danbooru or konachan or atfbooru or yandere) with a given tag. Tag is optional but preferred. Only 1 tag allowed.</value>
|
||||
</data>
|
||||
<data name="hentai_usage" xml:space="preserve">
|
||||
<value>`{0}hentai yuri`</value>
|
||||
@ -2623,7 +2623,7 @@
|
||||
<value>hentaibomb</value>
|
||||
</data>
|
||||
<data name="hentaibomb_desc" xml:space="preserve">
|
||||
<value>Shows a total 4 images (from gelbooru, danbooru, konachan and atfbooru). Tag is optional but preferred.</value>
|
||||
<value>Shows a total 5 images (from gelbooru, danbooru, konachan, yandere and atfbooru). Tag is optional but preferred.</value>
|
||||
</data>
|
||||
<data name="hentaibomb_usage" xml:space="preserve">
|
||||
<value>`{0}hentaibomb yuri`</value>
|
||||
@ -2691,4 +2691,13 @@
|
||||
<data name="bfu_usage" xml:space="preserve">
|
||||
<value>`{0}bfu platform game user`</value>
|
||||
</data>
|
||||
<data name="yandere_cmd" xml:space="preserve">
|
||||
<value>yandere</value>
|
||||
</data>
|
||||
<data name="yandere_desc" xml:space="preserve">
|
||||
<value>Shows a random image from yandere with a given tag. Tag is optional but preferred. (multiple tags are appended with +)</value>
|
||||
</data>
|
||||
<data name="yandere_usage" xml:space="preserve">
|
||||
<value>`{0}yandere tag1+tag2`</value>
|
||||
</data>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user