nsfw translated. whole 5 strings out of which 3 are the same. :)
This commit is contained in:
parent
813a9b7839
commit
e6af53d647
@ -20,8 +20,8 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
public class NSFW : NadekoModule
|
public class NSFW : NadekoModule
|
||||||
{
|
{
|
||||||
|
|
||||||
private static ConcurrentDictionary<ulong, Timer> AutoHentaiTimers { get; } = new ConcurrentDictionary<ulong, Timer>();
|
private static readonly ConcurrentDictionary<ulong, Timer> AutoHentaiTimers = new ConcurrentDictionary<ulong, Timer>();
|
||||||
private static ConcurrentHashSet<ulong> _hentaiBombBlacklist { get; } = new ConcurrentHashSet<ulong>();
|
private static readonly ConcurrentHashSet<ulong> HentaiBombBlacklist = new ConcurrentHashSet<ulong>();
|
||||||
|
|
||||||
private async Task InternalHentai(IMessageChannel channel, string tag, bool noError)
|
private async Task InternalHentai(IMessageChannel channel, string tag, bool noError)
|
||||||
{
|
{
|
||||||
@ -30,7 +30,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
tag = "rating%3Aexplicit+" + tag;
|
tag = "rating%3Aexplicit+" + tag;
|
||||||
|
|
||||||
var rng = new NadekoRandom();
|
var rng = new NadekoRandom();
|
||||||
Task<string> provider = Task.FromResult("");
|
var provider = Task.FromResult("");
|
||||||
switch (rng.Next(0, 4))
|
switch (rng.Next(0, 4))
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -45,20 +45,18 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
case 3:
|
case 3:
|
||||||
provider = GetYandereImageLink(tag);
|
provider = GetYandereImageLink(tag);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
var link = await provider.ConfigureAwait(false);
|
var link = await provider.ConfigureAwait(false);
|
||||||
if (string.IsNullOrWhiteSpace(link))
|
if (string.IsNullOrWhiteSpace(link))
|
||||||
{
|
{
|
||||||
if (!noError)
|
if (!noError)
|
||||||
await channel.SendErrorAsync("No results found.").ConfigureAwait(false);
|
await ReplyErrorLocalized("not_found").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
await channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||||
.WithImageUrl(link)
|
.WithImageUrl(link)
|
||||||
.WithDescription("Tag: " + tag))
|
.WithDescription($"{GetText("tag")}: " + tag))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,11 +72,10 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
|
|
||||||
if (interval == 0)
|
if (interval == 0)
|
||||||
{
|
{
|
||||||
if (AutoHentaiTimers.TryRemove(Context.Channel.Id, out t))
|
if (!AutoHentaiTimers.TryRemove(Context.Channel.Id, out t)) return;
|
||||||
{
|
|
||||||
t.Change(Timeout.Infinite, Timeout.Infinite); //proper way to disable the timer
|
t.Change(Timeout.Infinite, Timeout.Infinite); //proper way to disable the timer
|
||||||
await Context.Channel.SendConfirmAsync("Autohentai stopped.").ConfigureAwait(false);
|
await ReplyConfirmLocalized("autohentai_stopped").ConfigureAwait(false);
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +93,10 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
else
|
else
|
||||||
await InternalHentai(Context.Channel, tagsArr[new NadekoRandom().Next(0, tagsArr.Length)], true).ConfigureAwait(false);
|
await InternalHentai(Context.Channel, tagsArr[new NadekoRandom().Next(0, tagsArr.Length)], true).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
}, null, interval * 1000, interval * 1000);
|
}, null, interval * 1000, interval * 1000);
|
||||||
|
|
||||||
AutoHentaiTimers.AddOrUpdate(Context.Channel.Id, t, (key, old) =>
|
AutoHentaiTimers.AddOrUpdate(Context.Channel.Id, t, (key, old) =>
|
||||||
@ -105,15 +105,16 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
return t;
|
return t;
|
||||||
});
|
});
|
||||||
|
|
||||||
await Context.Channel.SendConfirmAsync($"Autohentai started. Reposting every {interval}s with one of the following tags:\n{string.Join(", ", tagsArr)}")
|
await ReplyConfirmLocalized("autohentai_started",
|
||||||
.ConfigureAwait(false);
|
interval,
|
||||||
|
string.Join(", ", tagsArr)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
public async Task HentaiBomb([Remainder] string tag = null)
|
public async Task HentaiBomb([Remainder] string tag = null)
|
||||||
{
|
{
|
||||||
if (!_hentaiBombBlacklist.Add(Context.User.Id))
|
if (!HentaiBombBlacklist.Add(Context.User.Id))
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -125,19 +126,19 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
GetKonachanImageLink(tag),
|
GetKonachanImageLink(tag),
|
||||||
GetYandereImageLink(tag)).ConfigureAwait(false);
|
GetYandereImageLink(tag)).ConfigureAwait(false);
|
||||||
|
|
||||||
var linksEnum = links?.Where(l => l != null);
|
var linksEnum = links?.Where(l => l != null).ToArray();
|
||||||
if (links == null || !linksEnum.Any())
|
if (links == null || !linksEnum.Any())
|
||||||
{
|
{
|
||||||
await Context.Channel.SendErrorAsync("No results found.").ConfigureAwait(false);
|
await ReplyErrorLocalized("not_found").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await Context.Channel.SendMessageAsync(String.Join("\n\n", linksEnum)).ConfigureAwait(false);
|
await Context.Channel.SendMessageAsync(string.Join("\n\n", linksEnum)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
await Task.Delay(5000).ConfigureAwait(false);
|
await Task.Delay(5000).ConfigureAwait(false);
|
||||||
_hentaiBombBlacklist.TryRemove(Context.User.Id);
|
HentaiBombBlacklist.TryRemove(Context.User.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -157,7 +158,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
var url = await GetE621ImageLink(tag).ConfigureAwait(false);
|
var url = await GetE621ImageLink(tag).ConfigureAwait(false);
|
||||||
|
|
||||||
if (url == null)
|
if (url == null)
|
||||||
await Context.Channel.SendErrorAsync(Context.User.Mention + " No results.");
|
await ReplyErrorLocalized("not_found").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||||
.WithDescription(Context.User.Mention + " " + tag)
|
.WithDescription(Context.User.Mention + " " + tag)
|
||||||
@ -178,7 +179,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
var url = await GetDanbooruImageLink(tag).ConfigureAwait(false);
|
var url = await GetDanbooruImageLink(tag).ConfigureAwait(false);
|
||||||
|
|
||||||
if (url == null)
|
if (url == null)
|
||||||
await Context.Channel.SendErrorAsync(Context.User.Mention + " No results.").ConfigureAwait(false);
|
await ReplyErrorLocalized("not_found").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||||
.WithDescription(Context.User.Mention + " " + tag)
|
.WithDescription(Context.User.Mention + " " + tag)
|
||||||
@ -227,9 +228,9 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
JToken obj;
|
JToken obj;
|
||||||
using (var http = new HttpClient())
|
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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -245,9 +246,9 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
JToken obj;
|
JToken obj;
|
||||||
using (var http = new HttpClient())
|
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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
37
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
37
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
@ -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>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to {0} has already fainted..
|
/// Looks up a localized string similar to {0} has already fainted..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -225,6 +225,12 @@
|
|||||||
<data name="customreactions_trigger" xml:space="preserve">
|
<data name="customreactions_trigger" xml:space="preserve">
|
||||||
<value>Trigger</value>
|
<value>Trigger</value>
|
||||||
</data>
|
</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">
|
<data name="pokemon_already_fainted" xml:space="preserve">
|
||||||
<value>{0} has already fainted.</value>
|
<value>{0} has already fainted.</value>
|
||||||
</data>
|
</data>
|
||||||
@ -292,4 +298,11 @@
|
|||||||
<data name="pokemon_you_fainted" xml:space="preserve">
|
<data name="pokemon_you_fainted" xml:space="preserve">
|
||||||
<value>You fainted, so you are not able to move!</value>
|
<value>You fainted, so you are not able to move!</value>
|
||||||
</data>
|
</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>
|
</root>
|
@ -292,4 +292,17 @@
|
|||||||
<data name="customreactions_trigger" xml:space="preserve">
|
<data name="customreactions_trigger" xml:space="preserve">
|
||||||
<value>Окидач</value>
|
<value>Окидач</value>
|
||||||
</data>
|
</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>
|
</root>
|
Loading…
Reference in New Issue
Block a user