Add Safeyandere, Moved Yandere to NSFW and added to 💣
This commit is contained in:
parent
0e2a92c5d3
commit
1ccc049655
@ -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,46 @@ 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;
|
||||
if (string.Equals(rating[rng.Next(0, rating.Count)].Groups["rate"].Value.ToString(), "e") || string.Equals(rating[rng.Next(0, rating.Count)].Groups["rate"].Value.ToString(), "q"))
|
||||
{
|
||||
return matches[rng.Next(0, matches.Count)].Groups["url"].Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[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)
|
||||
|
@ -388,12 +388,12 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Yandere(IUserMessage umsg, [Remainder] string tag = null)
|
||||
public async Task Safeyandere(IUserMessage umsg, [Remainder] string tag = null)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
|
||||
tag = tag?.Trim() ?? "";
|
||||
var link = await GetYandereImageLink(tag).ConfigureAwait(false);
|
||||
var link = await GetSafeYandereImageLink(tag).ConfigureAwait(false);
|
||||
if (link == null)
|
||||
await channel.SendMessageAsync("`No results.`");
|
||||
else
|
||||
@ -492,19 +492,29 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
||||
await channel.SendMessageAsync(await _google.ShortenUrl(usr.AvatarUrl).ConfigureAwait(false)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public static async Task<string> GetYandereImageLink(string tag)
|
||||
public static async Task<string> GetSafeYandereImageLink(string tag)
|
||||
{
|
||||
var rng = new NadekoRandom();
|
||||
var url =
|
||||
$"https://yande.re/post.xml?limit=100&tags={tag.Replace(" ", "_")}";
|
||||
$"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;
|
||||
var match = matches[rng.Next(0, matches.Count)];
|
||||
return matches[rng.Next(0, matches.Count)].Groups["url"].Value;
|
||||
if (string.Equals(rating[rng.Next(0, rating.Count)].Groups["rate"].Value.ToString(), "s") || string.Equals(rating[rng.Next(0, rating.Count)].Groups["rate"].Value.ToString(), "q"))
|
||||
{
|
||||
return matches[rng.Next(0, matches.Count)].Groups["url"].Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
85
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
85
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 {
|
||||
@ -6674,6 +6674,33 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to safeyandere sy.
|
||||
/// </summary>
|
||||
public static string safeyandere_cmd {
|
||||
get {
|
||||
return ResourceManager.GetString("sy_cmd", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Shows a safe random image from yandere with a given tag. Tag is optional but preferred. (multiple tags are appended with +).
|
||||
/// </summary>
|
||||
public static string safeyandere_desc {
|
||||
get {
|
||||
return ResourceManager.GetString("sy_desc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to `{0}sy tag1+tag2` or `{0}safeyandere tag1+tag2`.
|
||||
/// </summary>
|
||||
public static string safeyandere_usage {
|
||||
get {
|
||||
return ResourceManager.GetString("sy_usage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to take.
|
||||
/// </summary>
|
||||
@ -7700,6 +7727,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>
|
||||
@ -7753,32 +7807,5 @@ namespace NadekoBot.Resources {
|
||||
return ResourceManager.GetString("youtube_usage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,6 +2691,15 @@
|
||||
<data name="bfu_usage" xml:space="preserve">
|
||||
<value>`{0}bfu platform game user`</value>
|
||||
</data>
|
||||
<data name="safeyandere_cmd" xml:space="preserve">
|
||||
<value>safeyandere sy</value>
|
||||
</data>
|
||||
<data name="safeyandere_desc" xml:space="preserve">
|
||||
<value>Shows a safe random image from yandere with a given tag. Tag is optional but preferred. (multiple tags are appended with +)</value>
|
||||
</data>
|
||||
<data name="safeyandere_usage" xml:space="preserve">
|
||||
<value>`{0}sy tag1+tag2` or `{0}safeyandere tag1+tag2`</value>
|
||||
</data>
|
||||
<data name="yandere_cmd" xml:space="preserve">
|
||||
<value>yandere</value>
|
||||
</data>
|
||||
|
Loading…
Reference in New Issue
Block a user