diff --git a/src/NadekoBot/Modules/NSFW/NSFW.cs b/src/NadekoBot/Modules/NSFW/NSFW.cs index 52a38ce7..93834390 100644 --- a/src/NadekoBot/Modules/NSFW/NSFW.cs +++ b/src/NadekoBot/Modules/NSFW/NSFW.cs @@ -55,6 +55,20 @@ namespace NadekoBot.Modules.NSFW await channel.SendMessageAsync(link).ConfigureAwait(false); } + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Konachan(IUserMessage umsg, [Remainder] string tag = null) + { + var channel = (ITextChannel)umsg.Channel; + + tag = tag?.Trim() ?? ""; + var link = await GetKonachanImageLink(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 Gelbooru(IUserMessage umsg, [Remainder] string tag = null) @@ -147,6 +161,25 @@ namespace NadekoBot.Modules.NSFW } } + public static async Task GetKonachanImageLink(string tag) + { + var rng = new NadekoRandom(); + + var link = $"http://konachan.com/post?" + + $"page={rng.Next(0, 5)}"; + 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, ".*?)\">"); + + if (matches.Count == 0) + return null; + return await NadekoBot.Google.ShortenUrl(matches[rng.Next(0, matches.Count)].Groups["ll"].Value).ConfigureAwait(false); + } + } + public static async Task GetDanbooruImageLink(string tag) { var rng = new NadekoRandom(); diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 010083a4..e4a88408 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -3326,6 +3326,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to konachan. + /// + public static string konachan_cmd { + get { + return ResourceManager.GetString("konachan_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Shows a random hentai image from konachan with a given tag. Tag is optional but preffered. (multiple tags are appended with +). + /// + public static string konachan_desc { + get { + return ResourceManager.GetString("konachan_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `~konachan yuri`. + /// + public static string konachan_usage { + get { + return ResourceManager.GetString("konachan_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to lcsc. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 1fc359fd..c565e2f8 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2209,7 +2209,7 @@ safebooru - Shows a random image from safebooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +) + Shows a random image from safebooru with a given tag. Tag is optional but preferred. (multiple tags are appended with +) `~safebooru yuri+kissing` @@ -2263,7 +2263,7 @@ danbooru - Shows a random hentai image from danbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +) + Shows a random hentai image from danbooru with a given tag. Tag is optional but preferred. (multiple tags are appended with +) `~danbooru yuri+kissing` @@ -2272,7 +2272,7 @@ gelbooru - Shows a random hentai image from gelbooru with a given tag. Tag is optional but preffered. (multiple tags are appended with +) + Shows a random hentai image from gelbooru with a given tag. Tag is optional but preferred. (multiple tags are appended with +) `~gelbooru yuri+kissing` @@ -2281,7 +2281,7 @@ rule34 - Shows a random image from rule34.xx with a given tag. Tag is optional but preffered. (multiple tags are appended with +) + Shows a random image from rule34.xx with a given tag. Tag is optional but preferred. (multiple tags are appended with +) `~rule34 yuri+kissing` @@ -2290,7 +2290,7 @@ e621 - Shows a random hentai image from e621.net with a given tag. Tag is optional but preffered. Use spaces for multiple tags. + Shows a random hentai image from e621.net with a given tag. Tag is optional but preferred. Use spaces for multiple tags. `~e621 yuri kissing` @@ -2682,4 +2682,13 @@ `.voicemute @Someone` + + konachan + + + Shows a random hentai image from konachan with a given tag. Tag is optional but preferred. (multiple tags are appended with +) + + + `~konachan yuri` + \ No newline at end of file