nsfw translated. whole 5 strings out of which 3 are the same. :)

This commit is contained in:
Kwoth 2017-02-13 23:21:25 +01:00
parent 813a9b7839
commit e6af53d647
4 changed files with 90 additions and 26 deletions

View File

@ -20,8 +20,8 @@ namespace NadekoBot.Modules.NSFW
public class NSFW : NadekoModule
{
private static ConcurrentDictionary<ulong, Timer> AutoHentaiTimers { get; } = new ConcurrentDictionary<ulong, Timer>();
private static ConcurrentHashSet<ulong> _hentaiBombBlacklist { get; } = new ConcurrentHashSet<ulong>();
private static readonly ConcurrentDictionary<ulong, Timer> AutoHentaiTimers = new ConcurrentDictionary<ulong, Timer>();
private static readonly ConcurrentHashSet<ulong> HentaiBombBlacklist = new ConcurrentHashSet<ulong>();
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<string> 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)
{

View File

@ -383,6 +383,43 @@ namespace NadekoBot.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Autohentai started. Reposting every {0}s with one of the following tags:
///{1}.
/// </summary>
public static string nsfw_autohentai_started {
get {
return ResourceManager.GetString("nsfw_autohentai_started", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Autohentai stopped..
/// </summary>
public static string nsfw_autohentai_stopped {
get {
return ResourceManager.GetString("nsfw_autohentai_stopped", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to No results found..
/// </summary>
public static string nsfw_not_found {
get {
return ResourceManager.GetString("nsfw_not_found", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Tag.
/// </summary>
public static string nsfw_tag {
get {
return ResourceManager.GetString("nsfw_tag", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} has already fainted..
/// </summary>

View File

@ -225,6 +225,12 @@
<data name="customreactions_trigger" xml:space="preserve">
<value>Trigger</value>
</data>
<data name="nsfw_autohentai_stopped" xml:space="preserve">
<value>Autohentai stopped.</value>
</data>
<data name="nsfw_not_found" xml:space="preserve">
<value>No results found.</value>
</data>
<data name="pokemon_already_fainted" xml:space="preserve">
<value>{0} has already fainted.</value>
</data>
@ -292,4 +298,11 @@
<data name="pokemon_you_fainted" xml:space="preserve">
<value>You fainted, so you are not able to move!</value>
</data>
<data name="nsfw_autohentai_started" xml:space="preserve">
<value>Autohentai started. Reposting every {0}s with one of the following tags:
{1}</value>
</data>
<data name="nsfw_tag" xml:space="preserve">
<value>Tag</value>
</data>
</root>

View File

@ -292,4 +292,17 @@
<data name="customreactions_trigger" xml:space="preserve">
<value>Окидач</value>
</data>
<data name="nsfw_autohentai_started" xml:space="preserve">
<value>Аутохентаи започет. Постоваћу сваких {0} сек. користећи један од следећих тагова:
{1}</value>
</data>
<data name="nsfw_autohentai_stopped" xml:space="preserve">
<value>АутоХентаи заустављен.</value>
</data>
<data name="nsfw_no_results" xml:space="preserve">
<value>Нема резултата.</value>
</data>
<data name="nsfw_tag" xml:space="preserve">
<value>Таг</value>
</data>
</root>