currency events localizable 🆗
This commit is contained in:
parent
5ed0ee4ef8
commit
1804b81b8a
@ -5,12 +5,9 @@ using NadekoBot.Extensions;
|
|||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NadekoBot.Services.Database;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
@ -27,7 +24,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
SneakyGameStatus
|
SneakyGameStatus
|
||||||
}
|
}
|
||||||
//flower reaction event
|
//flower reaction event
|
||||||
public static readonly ConcurrentHashSet<ulong> _sneakyGameAwardedUsers = new ConcurrentHashSet<ulong>();
|
private static readonly ConcurrentHashSet<ulong> _sneakyGameAwardedUsers = new ConcurrentHashSet<ulong>();
|
||||||
|
|
||||||
|
|
||||||
private static readonly char[] _sneakyGameStatusChars = Enumerable.Range(48, 10)
|
private static readonly char[] _sneakyGameStatusChars = Enumerable.Range(48, 10)
|
||||||
@ -36,7 +33,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
.Select(x => (char)x)
|
.Select(x => (char)x)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
private static string _secretCode = String.Empty;
|
private static string _secretCode = string.Empty;
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
@ -54,7 +51,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task SneakyGameStatusEvent(CommandContext Context, int? arg)
|
public async Task SneakyGameStatusEvent(CommandContext context, int? arg)
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
if (arg == null || arg < 5)
|
if (arg == null || arg < 5)
|
||||||
@ -62,11 +59,11 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
else
|
else
|
||||||
num = arg.Value;
|
num = arg.Value;
|
||||||
|
|
||||||
if (_secretCode != String.Empty)
|
if (_secretCode != string.Empty)
|
||||||
return;
|
return;
|
||||||
var rng = new NadekoRandom();
|
var rng = new NadekoRandom();
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++)
|
for (var i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
_secretCode += _sneakyGameStatusChars[rng.Next(0, _sneakyGameStatusChars.Length)];
|
_secretCode += _sneakyGameStatusChars[rng.Next(0, _sneakyGameStatusChars.Length)];
|
||||||
}
|
}
|
||||||
@ -75,10 +72,9 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await Context.Channel.SendConfirmAsync($"SneakyGameStatus event started",
|
var title = GetText("sneakygamestatus_title");
|
||||||
$"Users must type a secret code to get 100 currency.\n" +
|
var desc = GetText("sneakygamestatus_desc", Format.Bold(100.ToString()) + CurrencySign, Format.Bold(num.ToString()));
|
||||||
$"Lasts {num} seconds. Don't tell anyone. Shhh.")
|
await context.Channel.SendConfirmAsync(title, desc).ConfigureAwait(false);
|
||||||
.ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -92,9 +88,9 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
|
|
||||||
var cnt = _sneakyGameAwardedUsers.Count;
|
var cnt = _sneakyGameAwardedUsers.Count;
|
||||||
_sneakyGameAwardedUsers.Clear();
|
_sneakyGameAwardedUsers.Clear();
|
||||||
_secretCode = String.Empty;
|
_secretCode = string.Empty;
|
||||||
|
|
||||||
await NadekoBot.Client.SetGameAsync($"SneakyGame event ended. {cnt} users received a reward.")
|
await NadekoBot.Client.SetGameAsync(GetText("sneakygamestatus_end", cnt))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,22 +115,31 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
return Task.Delay(0);
|
return Task.Delay(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task FlowerReactionEvent(CommandContext context) =>
|
public async Task FlowerReactionEvent(CommandContext context)
|
||||||
new FlowerReactionEvent().Start(context);
|
{
|
||||||
|
var title = GetText("flowerreaction_title");
|
||||||
|
var desc = GetText("flowerreaction_desc", "🌸", Format.Bold(100.ToString()) + CurrencySign);
|
||||||
|
var footer = GetText("flowerreaction_footer", 24);
|
||||||
|
var msg = await context.Channel.SendConfirmAsync(title,
|
||||||
|
desc, footer: footer)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
await new FlowerReactionEvent().Start(msg, context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class CurrencyEvent
|
public abstract class CurrencyEvent
|
||||||
{
|
{
|
||||||
public abstract Task Start(CommandContext channel);
|
public abstract Task Start(IUserMessage msg, CommandContext channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FlowerReactionEvent : CurrencyEvent
|
public class FlowerReactionEvent : CurrencyEvent
|
||||||
{
|
{
|
||||||
public readonly ConcurrentHashSet<ulong> _flowerReactionAwardedUsers = new ConcurrentHashSet<ulong>();
|
private readonly ConcurrentHashSet<ulong> _flowerReactionAwardedUsers = new ConcurrentHashSet<ulong>();
|
||||||
private readonly Logger _log;
|
private readonly Logger _log;
|
||||||
|
|
||||||
private IUserMessage msg { get; set; } = null;
|
private IUserMessage msg { get; set; }
|
||||||
|
|
||||||
private CancellationTokenSource source { get; }
|
private CancellationTokenSource source { get; }
|
||||||
private CancellationToken cancelToken { get; }
|
private CancellationToken cancelToken { get; }
|
||||||
@ -167,13 +172,9 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task Start(CommandContext context)
|
public override async Task Start(IUserMessage umsg, CommandContext context)
|
||||||
{
|
{
|
||||||
msg = await context.Channel.SendConfirmAsync("Flower reaction event started!",
|
msg = umsg;
|
||||||
"Add 🌸 reaction to this message to get 100" + NadekoBot.BotConfig.CurrencySign,
|
|
||||||
footer: "This event is active for up to 24 hours.")
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
NadekoBot.Client.MessageDeleted += MessageDeletedEventHandler;
|
NadekoBot.Client.MessageDeleted += MessageDeletedEventHandler;
|
||||||
|
|
||||||
try { await msg.AddReactionAsync("🌸").ConfigureAwait(false); }
|
try { await msg.AddReactionAsync("🌸").ConfigureAwait(false); }
|
||||||
|
55
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
55
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
@ -2144,6 +2144,33 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Add {0} reaction to this message to get {1} .
|
||||||
|
/// </summary>
|
||||||
|
public static string gambling_flowerreaction_desc {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("gambling_flowerreaction_desc", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to This event is active for up to {0} hours..
|
||||||
|
/// </summary>
|
||||||
|
public static string gambling_flowerreaction_footer {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("gambling_flowerreaction_footer", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Flower reaction event started!.
|
||||||
|
/// </summary>
|
||||||
|
public static string gambling_flowerreaction_title {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("gambling_flowerreaction_title", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to has gifted {0} to {1}.
|
/// Looks up a localized string similar to has gifted {0} to {1}.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -2297,6 +2324,34 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Users must type a secret code to get {0}.
|
||||||
|
///Lasts {1} seconds. Don't tell anyone. Shhh..
|
||||||
|
/// </summary>
|
||||||
|
public static string gambling_sneakygamestatus_desc {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("gambling_sneakygamestatus_desc", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to SneakyGame event ended. {0} users received the reward..
|
||||||
|
/// </summary>
|
||||||
|
public static string gambling_sneakygamestatus_end {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("gambling_sneakygamestatus_end", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to SneakyGameStatus event started.
|
||||||
|
/// </summary>
|
||||||
|
public static string gambling_sneakygamestatus_title {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("gambling_sneakygamestatus_title", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Tails.
|
/// Looks up a localized string similar to Tails.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -895,6 +895,15 @@ Reason: {1}</value>
|
|||||||
<data name="gambling_flip_invalid" xml:space="preserve">
|
<data name="gambling_flip_invalid" xml:space="preserve">
|
||||||
<value>Invalid number specified. You can flip 1 to {0} coins.</value>
|
<value>Invalid number specified. You can flip 1 to {0} coins.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="gambling_flowerreaction_desc" xml:space="preserve">
|
||||||
|
<value>Add {0} reaction to this message to get {1} </value>
|
||||||
|
</data>
|
||||||
|
<data name="gambling_flowerreaction_footer" xml:space="preserve">
|
||||||
|
<value>This event is active for up to {0} hours.</value>
|
||||||
|
</data>
|
||||||
|
<data name="gambling_flowerreaction_title" xml:space="preserve">
|
||||||
|
<value>Flower reaction event started!</value>
|
||||||
|
</data>
|
||||||
<data name="gambling_gifted" xml:space="preserve">
|
<data name="gambling_gifted" xml:space="preserve">
|
||||||
<value>has gifted {0} to {1}</value>
|
<value>has gifted {0} to {1}</value>
|
||||||
<comment>X has gifted 15 flowers to Y</comment>
|
<comment>X has gifted 15 flowers to Y</comment>
|
||||||
@ -948,6 +957,16 @@ Reason: {1}</value>
|
|||||||
<data name="gambling_slot_won" xml:space="preserve">
|
<data name="gambling_slot_won" xml:space="preserve">
|
||||||
<value>Won</value>
|
<value>Won</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="gambling_sneakygamestatus_desc" xml:space="preserve">
|
||||||
|
<value>Users must type a secret code to get {0}.
|
||||||
|
Lasts {1} seconds. Don't tell anyone. Shhh.</value>
|
||||||
|
</data>
|
||||||
|
<data name="gambling_sneakygamestatus_end" xml:space="preserve">
|
||||||
|
<value>SneakyGame event ended. {0} users received the reward.</value>
|
||||||
|
</data>
|
||||||
|
<data name="gambling_sneakygamestatus_title" xml:space="preserve">
|
||||||
|
<value>SneakyGameStatus event started</value>
|
||||||
|
</data>
|
||||||
<data name="gambling_tails" xml:space="preserve">
|
<data name="gambling_tails" xml:space="preserve">
|
||||||
<value>Tails</value>
|
<value>Tails</value>
|
||||||
</data>
|
</data>
|
||||||
|
Loading…
Reference in New Issue
Block a user