From e6af53d6473bd269ea8f3010ea0249252c5f02e9 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 13 Feb 2017 23:21:25 +0100 Subject: [PATCH] nsfw translated. whole 5 strings out of which 3 are the same. :) --- src/NadekoBot/Modules/NSFW/NSFW.cs | 53 ++++++++++--------- .../Resources/ResponseStrings.Designer.cs | 37 +++++++++++++ src/NadekoBot/Resources/ResponseStrings.resx | 13 +++++ .../Resources/ResponseStrings.sr-cyrl-rs.resx | 13 +++++ 4 files changed, 90 insertions(+), 26 deletions(-) diff --git a/src/NadekoBot/Modules/NSFW/NSFW.cs b/src/NadekoBot/Modules/NSFW/NSFW.cs index c2e42d58..5538e8d6 100644 --- a/src/NadekoBot/Modules/NSFW/NSFW.cs +++ b/src/NadekoBot/Modules/NSFW/NSFW.cs @@ -20,8 +20,8 @@ namespace NadekoBot.Modules.NSFW public class NSFW : NadekoModule { - private static ConcurrentDictionary AutoHentaiTimers { get; } = new ConcurrentDictionary(); - private static ConcurrentHashSet _hentaiBombBlacklist { get; } = new ConcurrentHashSet(); + private static readonly ConcurrentDictionary AutoHentaiTimers = new ConcurrentDictionary(); + private static readonly ConcurrentHashSet HentaiBombBlacklist = new ConcurrentHashSet(); private async Task InternalHentai(IMessageChannel channel, string tag, bool noError) { @@ -30,7 +30,7 @@ namespace NadekoBot.Modules.NSFW tag = "rating%3Aexplicit+" + tag; var rng = new NadekoRandom(); - Task provider = Task.FromResult(""); + var provider = Task.FromResult(""); switch (rng.Next(0, 4)) { case 0: @@ -45,20 +45,18 @@ namespace NadekoBot.Modules.NSFW case 3: provider = GetYandereImageLink(tag); break; - default: - break; } var link = await provider.ConfigureAwait(false); if (string.IsNullOrWhiteSpace(link)) { if (!noError) - await channel.SendErrorAsync("No results found.").ConfigureAwait(false); + await ReplyErrorLocalized("not_found").ConfigureAwait(false); return; } await channel.EmbedAsync(new EmbedBuilder().WithOkColor() .WithImageUrl(link) - .WithDescription("Tag: " + tag)) + .WithDescription($"{GetText("tag")}: " + tag)) .ConfigureAwait(false); } @@ -74,11 +72,10 @@ namespace NadekoBot.Modules.NSFW if (interval == 0) { - if (AutoHentaiTimers.TryRemove(Context.Channel.Id, out t)) - { - t.Change(Timeout.Infinite, Timeout.Infinite); //proper way to disable the timer - await Context.Channel.SendConfirmAsync("Autohentai stopped.").ConfigureAwait(false); - } + if (!AutoHentaiTimers.TryRemove(Context.Channel.Id, out t)) return; + + t.Change(Timeout.Infinite, Timeout.Infinite); //proper way to disable the timer + await ReplyConfirmLocalized("autohentai_stopped").ConfigureAwait(false); return; } @@ -96,7 +93,10 @@ namespace NadekoBot.Modules.NSFW else await InternalHentai(Context.Channel, tagsArr[new NadekoRandom().Next(0, tagsArr.Length)], true).ConfigureAwait(false); } - catch { } + catch + { + // ignored + } }, null, interval * 1000, interval * 1000); AutoHentaiTimers.AddOrUpdate(Context.Channel.Id, t, (key, old) => @@ -105,15 +105,16 @@ namespace NadekoBot.Modules.NSFW return t; }); - await Context.Channel.SendConfirmAsync($"Autohentai started. Reposting every {interval}s with one of the following tags:\n{string.Join(", ", tagsArr)}") - .ConfigureAwait(false); + await ReplyConfirmLocalized("autohentai_started", + interval, + string.Join(", ", tagsArr)).ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] public async Task HentaiBomb([Remainder] string tag = null) { - if (!_hentaiBombBlacklist.Add(Context.User.Id)) + if (!HentaiBombBlacklist.Add(Context.User.Id)) return; try { @@ -125,19 +126,19 @@ namespace NadekoBot.Modules.NSFW GetKonachanImageLink(tag), GetYandereImageLink(tag)).ConfigureAwait(false); - var linksEnum = links?.Where(l => l != null); + var linksEnum = links?.Where(l => l != null).ToArray(); if (links == null || !linksEnum.Any()) { - await Context.Channel.SendErrorAsync("No results found.").ConfigureAwait(false); + await ReplyErrorLocalized("not_found").ConfigureAwait(false); return; } - await Context.Channel.SendMessageAsync(String.Join("\n\n", linksEnum)).ConfigureAwait(false); + await Context.Channel.SendMessageAsync(string.Join("\n\n", linksEnum)).ConfigureAwait(false); } finally { await Task.Delay(5000).ConfigureAwait(false); - _hentaiBombBlacklist.TryRemove(Context.User.Id); + HentaiBombBlacklist.TryRemove(Context.User.Id); } } #endif @@ -157,7 +158,7 @@ namespace NadekoBot.Modules.NSFW var url = await GetE621ImageLink(tag).ConfigureAwait(false); if (url == null) - await Context.Channel.SendErrorAsync(Context.User.Mention + " No results."); + await ReplyErrorLocalized("not_found").ConfigureAwait(false); else await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor() .WithDescription(Context.User.Mention + " " + tag) @@ -178,7 +179,7 @@ namespace NadekoBot.Modules.NSFW var url = await GetDanbooruImageLink(tag).ConfigureAwait(false); if (url == null) - await Context.Channel.SendErrorAsync(Context.User.Mention + " No results.").ConfigureAwait(false); + await ReplyErrorLocalized("not_found").ConfigureAwait(false); else await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor() .WithDescription(Context.User.Mention + " " + tag) @@ -227,9 +228,9 @@ namespace NadekoBot.Modules.NSFW JToken obj; using (var http = new HttpClient()) { - obj = JArray.Parse(await http.GetStringAsync($"http://api.oboobs.ru/boobs/{ new NadekoRandom().Next(0, 10330) }").ConfigureAwait(false))[0]; + obj = JArray.Parse(await http.GetStringAsync($"http://api.oboobs.ru/boobs/{new NadekoRandom().Next(0, 10330)}").ConfigureAwait(false))[0]; } - await Context.Channel.SendMessageAsync($"http://media.oboobs.ru/{ obj["preview"].ToString() }").ConfigureAwait(false); + await Context.Channel.SendMessageAsync($"http://media.oboobs.ru/{obj["preview"]}").ConfigureAwait(false); } catch (Exception ex) { @@ -245,9 +246,9 @@ namespace NadekoBot.Modules.NSFW JToken obj; using (var http = new HttpClient()) { - obj = JArray.Parse(await http.GetStringAsync($"http://api.obutts.ru/butts/{ new NadekoRandom().Next(0, 4335) }").ConfigureAwait(false))[0]; + obj = JArray.Parse(await http.GetStringAsync($"http://api.obutts.ru/butts/{new NadekoRandom().Next(0, 4335)}").ConfigureAwait(false))[0]; } - await Context.Channel.SendMessageAsync($"http://media.obutts.ru/{ obj["preview"].ToString() }").ConfigureAwait(false); + await Context.Channel.SendMessageAsync($"http://media.obutts.ru/{obj["preview"]}").ConfigureAwait(false); } catch (Exception ex) { diff --git a/src/NadekoBot/Resources/ResponseStrings.Designer.cs b/src/NadekoBot/Resources/ResponseStrings.Designer.cs index 342b3967..23b6abda 100644 --- a/src/NadekoBot/Resources/ResponseStrings.Designer.cs +++ b/src/NadekoBot/Resources/ResponseStrings.Designer.cs @@ -383,6 +383,43 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to Autohentai started. Reposting every {0}s with one of the following tags: + ///{1}. + /// + public static string nsfw_autohentai_started { + get { + return ResourceManager.GetString("nsfw_autohentai_started", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Autohentai stopped.. + /// + public static string nsfw_autohentai_stopped { + get { + return ResourceManager.GetString("nsfw_autohentai_stopped", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No results found.. + /// + public static string nsfw_not_found { + get { + return ResourceManager.GetString("nsfw_not_found", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Tag. + /// + public static string nsfw_tag { + get { + return ResourceManager.GetString("nsfw_tag", resourceCulture); + } + } + /// /// Looks up a localized string similar to {0} has already fainted.. /// diff --git a/src/NadekoBot/Resources/ResponseStrings.resx b/src/NadekoBot/Resources/ResponseStrings.resx index a6728d5f..80ada81e 100644 --- a/src/NadekoBot/Resources/ResponseStrings.resx +++ b/src/NadekoBot/Resources/ResponseStrings.resx @@ -225,6 +225,12 @@ Trigger + + Autohentai stopped. + + + No results found. + {0} has already fainted. @@ -292,4 +298,11 @@ You fainted, so you are not able to move! + + Autohentai started. Reposting every {0}s with one of the following tags: +{1} + + + Tag + \ No newline at end of file diff --git a/src/NadekoBot/Resources/ResponseStrings.sr-cyrl-rs.resx b/src/NadekoBot/Resources/ResponseStrings.sr-cyrl-rs.resx index e3d4d417..5b59766c 100644 --- a/src/NadekoBot/Resources/ResponseStrings.sr-cyrl-rs.resx +++ b/src/NadekoBot/Resources/ResponseStrings.sr-cyrl-rs.resx @@ -292,4 +292,17 @@ Окидач + + Аутохентаи започет. Постоваћу сваких {0} сек. користећи један од следећих тагова: +{1} + + + АутоХентаи заустављен. + + + Нема резултата. + + + Таг + \ No newline at end of file