Remove safeyandere.

This commit is contained in:
fkndean 2016-11-14 17:20:45 -05:00
parent 96dd0b6096
commit 581ab1edeb
4 changed files with 2 additions and 85 deletions

View File

@ -111,18 +111,11 @@ namespace NadekoBot.Modules.NSFW
{
var webpage = await http.GetStringAsync(url).ConfigureAwait(false);
var matches = Regex.Matches(webpage, "file_url=\"(?<url>.*?)\"");
var rating = Regex.Matches(webpage, "rating=\"(?<rate>.*?)\"");
//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]

View File

@ -386,20 +386,6 @@ $@"🌍 **Weather for** 【{obj["target"]}】
await channel.SendMessageAsync($"https://images.google.com/searchbyimage?image_url={imageLink}").ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task Safeyandere(IUserMessage umsg, [Remainder] string tag = null)
{
var channel = (ITextChannel)umsg.Channel;
tag = tag?.Trim() ?? "";
var link = await GetSafeYandereImageLink(tag).ConfigureAwait(false);
if (link == null)
await channel.SendMessageAsync("`No results.`");
else
await channel.SendMessageAsync(link).ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task Safebooru(IUserMessage umsg, [Remainder] string tag = null)
@ -492,32 +478,6 @@ $@"🌍 **Weather for** 【{obj["target"]}】
await channel.SendMessageAsync(await _google.ShortenUrl(usr.AvatarUrl).ConfigureAwait(false)).ConfigureAwait(false);
}
public static async Task<string> GetSafeYandereImageLink(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(), "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;
}
}
}
public static async Task<string> GetSafebooruImageLink(string tag)
{
var rng = new NadekoRandom();

View File

@ -6674,33 +6674,6 @@ 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>

View File

@ -2691,15 +2691,6 @@
<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>