.bce command added, you can now edit BotConfig without editing the database and restarting the bot. Cleanup
This commit is contained in:
parent
fe88611183
commit
9163510eee
@ -1,7 +1,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NadekoBot.Services;
|
|
||||||
using NadekoBot.Services.Impl;
|
using NadekoBot.Services.Impl;
|
||||||
|
|
||||||
namespace NadekoBot.Common.Attributes
|
namespace NadekoBot.Common.Attributes
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NadekoBot.Services;
|
|
||||||
using NadekoBot.Services.Impl;
|
using NadekoBot.Services.Impl;
|
||||||
|
|
||||||
namespace NadekoBot.Common.Attributes
|
namespace NadekoBot.Common.Attributes
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NadekoBot.Services;
|
|
||||||
using NadekoBot.Services.Impl;
|
using NadekoBot.Services.Impl;
|
||||||
|
|
||||||
namespace NadekoBot.Common.Attributes
|
namespace NadekoBot.Common.Attributes
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NadekoBot.Services;
|
|
||||||
using NadekoBot.Services.Impl;
|
using NadekoBot.Services.Impl;
|
||||||
|
|
||||||
namespace NadekoBot.Common.Attributes
|
namespace NadekoBot.Common.Attributes
|
||||||
|
20
src/NadekoBot/Common/BotConfigEditType.cs
Normal file
20
src/NadekoBot/Common/BotConfigEditType.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
namespace NadekoBot.Common
|
||||||
|
{
|
||||||
|
public enum BotConfigEditType
|
||||||
|
{
|
||||||
|
CurrencyGenerationChance,
|
||||||
|
CurrencyGenerationCooldown,
|
||||||
|
CurrencyName,
|
||||||
|
CurrencyPluralName,
|
||||||
|
CurrencySign,
|
||||||
|
DmHelpString,
|
||||||
|
HelpString,
|
||||||
|
CurrencyDropAmount,
|
||||||
|
CurrencyDropAmountMax,
|
||||||
|
MinimumBetAmount,
|
||||||
|
TriviaCurrencyReward,
|
||||||
|
|
||||||
|
//ErrorColor, //after i fix the nadekobot.cs static variables
|
||||||
|
//OkColor
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
namespace NadekoBot.Migrations
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
namespace NadekoBot.Migrations
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
namespace NadekoBot.Migrations
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
namespace NadekoBot.Migrations
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
namespace NadekoBot.Migrations
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
namespace NadekoBot.Migrations
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using NadekoBot.Services.Database;
|
using NadekoBot.Services.Database;
|
||||||
using NadekoBot.Services.Database.Models;
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations
|
namespace NadekoBot.Migrations
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Modules.Permissions;
|
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
using System;
|
using System;
|
||||||
|
@ -5,7 +5,6 @@ using NadekoBot.Extensions;
|
|||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -29,14 +29,16 @@ namespace NadekoBot.Modules.Administration
|
|||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
private readonly IImagesService _images;
|
private readonly IImagesService _images;
|
||||||
private readonly MusicService _music;
|
private readonly MusicService _music;
|
||||||
|
private readonly IBotConfigProvider _bc;
|
||||||
|
|
||||||
public SelfCommands(DbService db, DiscordSocketClient client,
|
public SelfCommands(DbService db, DiscordSocketClient client,
|
||||||
MusicService music, IImagesService images)
|
MusicService music, IImagesService images, IBotConfigProvider bc)
|
||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
_client = client;
|
_client = client;
|
||||||
_images = images;
|
_images = images;
|
||||||
_music = music;
|
_music = music;
|
||||||
|
_bc = bc;
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
@ -179,9 +181,11 @@ namespace NadekoBot.Modules.Administration
|
|||||||
using (var uow = _db.UnitOfWork)
|
using (var uow = _db.UnitOfWork)
|
||||||
{
|
{
|
||||||
var config = uow.BotConfig.GetOrCreate();
|
var config = uow.BotConfig.GetOrCreate();
|
||||||
_service.ForwardDMs = config.ForwardMessages = !config.ForwardMessages;
|
config.ForwardMessages = !config.ForwardMessages;
|
||||||
uow.Complete();
|
uow.Complete();
|
||||||
}
|
}
|
||||||
|
_bc.Reload();
|
||||||
|
|
||||||
if (_service.ForwardDMs)
|
if (_service.ForwardDMs)
|
||||||
await ReplyConfirmLocalized("fwdm_start").ConfigureAwait(false);
|
await ReplyConfirmLocalized("fwdm_start").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
@ -196,9 +200,11 @@ namespace NadekoBot.Modules.Administration
|
|||||||
{
|
{
|
||||||
var config = uow.BotConfig.GetOrCreate();
|
var config = uow.BotConfig.GetOrCreate();
|
||||||
lock (_locker)
|
lock (_locker)
|
||||||
_service.ForwardDMsToAllOwners = config.ForwardToAllOwners = !config.ForwardToAllOwners;
|
config.ForwardToAllOwners = !config.ForwardToAllOwners;
|
||||||
uow.Complete();
|
uow.Complete();
|
||||||
}
|
}
|
||||||
|
_bc.Reload();
|
||||||
|
|
||||||
if (_service.ForwardDMsToAllOwners)
|
if (_service.ForwardDMsToAllOwners)
|
||||||
await ReplyConfirmLocalized("fwall_start").ConfigureAwait(false);
|
await ReplyConfirmLocalized("fwall_start").ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -8,7 +8,6 @@ using NadekoBot.Common;
|
|||||||
using NadekoBot.Common.ModuleBehaviors;
|
using NadekoBot.Common.ModuleBehaviors;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using NadekoBot.Services.Database.Models;
|
|
||||||
using NadekoBot.Services.Impl;
|
using NadekoBot.Services.Impl;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
@ -16,8 +15,9 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
{
|
{
|
||||||
public class SelfService : ILateExecutor, INService
|
public class SelfService : ILateExecutor, INService
|
||||||
{
|
{
|
||||||
public volatile bool ForwardDMs;
|
//todo bot config
|
||||||
public volatile bool ForwardDMsToAllOwners;
|
public bool ForwardDMs => _bc.BotConfig.ForwardMessages;
|
||||||
|
public bool ForwardDMsToAllOwners => _bc.BotConfig.ForwardToAllOwners;
|
||||||
|
|
||||||
private readonly NadekoBot _bot;
|
private readonly NadekoBot _bot;
|
||||||
private readonly CommandHandler _cmdHandler;
|
private readonly CommandHandler _cmdHandler;
|
||||||
@ -28,9 +28,10 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
private readonly IBotCredentials _creds;
|
private readonly IBotCredentials _creds;
|
||||||
private ImmutableArray<AsyncLazy<IDMChannel>> ownerChannels = new ImmutableArray<AsyncLazy<IDMChannel>>();
|
private ImmutableArray<AsyncLazy<IDMChannel>> ownerChannels = new ImmutableArray<AsyncLazy<IDMChannel>>();
|
||||||
|
private readonly IBotConfigProvider _bc;
|
||||||
|
|
||||||
public SelfService(DiscordSocketClient client, NadekoBot bot, CommandHandler cmdHandler, DbService db,
|
public SelfService(DiscordSocketClient client, NadekoBot bot, CommandHandler cmdHandler, DbService db,
|
||||||
BotConfig bc, ILocalization localization, NadekoStrings strings, IBotCredentials creds)
|
IBotConfigProvider bc, ILocalization localization, NadekoStrings strings, IBotCredentials creds)
|
||||||
{
|
{
|
||||||
_bot = bot;
|
_bot = bot;
|
||||||
_cmdHandler = cmdHandler;
|
_cmdHandler = cmdHandler;
|
||||||
@ -40,15 +41,13 @@ namespace NadekoBot.Modules.Administration.Services
|
|||||||
_strings = strings;
|
_strings = strings;
|
||||||
_client = client;
|
_client = client;
|
||||||
_creds = creds;
|
_creds = creds;
|
||||||
|
_bc = bc;
|
||||||
ForwardDMs = bc.ForwardMessages;
|
|
||||||
ForwardDMsToAllOwners = bc.ForwardToAllOwners;
|
|
||||||
|
|
||||||
var _ = Task.Run(async () =>
|
var _ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await bot.Ready.Task.ConfigureAwait(false);
|
await bot.Ready.Task.ConfigureAwait(false);
|
||||||
|
|
||||||
foreach (var cmd in bc.StartupCommands)
|
foreach (var cmd in bc.BotConfig.StartupCommands)
|
||||||
{
|
{
|
||||||
await cmdHandler.ExecuteExternal(cmd.GuildId, cmd.ChannelId, cmd.CommandText);
|
await cmdHandler.ExecuteExternal(cmd.GuildId, cmd.ChannelId, cmd.CommandText);
|
||||||
await Task.Delay(400).ConfigureAwait(false);
|
await Task.Delay(400).ConfigureAwait(false);
|
||||||
|
@ -4,7 +4,6 @@ using Discord;
|
|||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Modules.CustomReactions.Services;
|
using NadekoBot.Modules.CustomReactions.Services;
|
||||||
using NadekoBot.Services;
|
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -30,11 +30,11 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
|||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
private readonly PermissionService _perms;
|
private readonly PermissionService _perms;
|
||||||
private readonly CommandHandler _cmd;
|
private readonly CommandHandler _cmd;
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
private readonly NadekoStrings _strings;
|
private readonly NadekoStrings _strings;
|
||||||
|
|
||||||
public CustomReactionsService(PermissionService perms, DbService db, NadekoStrings strings,
|
public CustomReactionsService(PermissionService perms, DbService db, NadekoStrings strings,
|
||||||
DiscordSocketClient client, CommandHandler cmd, BotConfig bc, IUnitOfWork uow)
|
DiscordSocketClient client, CommandHandler cmd, IBotConfigProvider bc, IUnitOfWork uow)
|
||||||
{
|
{
|
||||||
_log = LogManager.GetCurrentClassLogger();
|
_log = LogManager.GetCurrentClassLogger();
|
||||||
_db = db;
|
_db = db;
|
||||||
@ -69,7 +69,7 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
|||||||
|
|
||||||
var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%");
|
var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%");
|
||||||
var trigger = cr.TriggerWithContext(umsg, _client).Trim().ToLowerInvariant();
|
var trigger = cr.TriggerWithContext(umsg, _client).Trim().ToLowerInvariant();
|
||||||
return ((hasTarget && content.StartsWith(trigger + " ")) || (_bc.CustomReactionsStartWith && content.StartsWith(trigger + " ")) || content == trigger);
|
return ((hasTarget && content.StartsWith(trigger + " ")) || (_bc.BotConfig.CustomReactionsStartWith && content.StartsWith(trigger + " ")) || content == trigger);
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
|
|
||||||
if (rs.Length != 0)
|
if (rs.Length != 0)
|
||||||
@ -90,7 +90,7 @@ namespace NadekoBot.Modules.CustomReactions.Services
|
|||||||
return false;
|
return false;
|
||||||
var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%");
|
var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%");
|
||||||
var trigger = cr.TriggerWithContext(umsg, _client).Trim().ToLowerInvariant();
|
var trigger = cr.TriggerWithContext(umsg, _client).Trim().ToLowerInvariant();
|
||||||
return ((hasTarget && content.StartsWith(trigger + " ")) || (_bc.CustomReactionsStartWith && content.StartsWith(trigger + " ")) || content == trigger);
|
return ((hasTarget && content.StartsWith(trigger + " ")) || (_bc.BotConfig.CustomReactionsStartWith && content.StartsWith(trigger + " ")) || content == trigger);
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
if (grs.Length == 0)
|
if (grs.Length == 0)
|
||||||
return null;
|
return null;
|
||||||
|
@ -3,7 +3,6 @@ using Discord.Commands;
|
|||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using NadekoBot.Services.Database.Models;
|
|
||||||
using NLog;
|
using NLog;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
@ -22,14 +21,14 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
[Group]
|
[Group]
|
||||||
public class AnimalRacingCommands : NadekoSubmodule
|
public class AnimalRacingCommands : NadekoSubmodule
|
||||||
{
|
{
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
private readonly CurrencyService _cs;
|
private readonly CurrencyService _cs;
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
|
|
||||||
|
|
||||||
public static ConcurrentDictionary<ulong, AnimalRace> AnimalRaces { get; } = new ConcurrentDictionary<ulong, AnimalRace>();
|
public static ConcurrentDictionary<ulong, AnimalRace> AnimalRaces { get; } = new ConcurrentDictionary<ulong, AnimalRace>();
|
||||||
|
|
||||||
public AnimalRacingCommands(BotConfig bc, CurrencyService cs, DiscordSocketClient client)
|
public AnimalRacingCommands(IBotConfigProvider bc, CurrencyService cs, DiscordSocketClient client)
|
||||||
{
|
{
|
||||||
_bc = bc;
|
_bc = bc;
|
||||||
_cs = cs;
|
_cs = cs;
|
||||||
@ -82,7 +81,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
private readonly Logger _log;
|
private readonly Logger _log;
|
||||||
|
|
||||||
private readonly ITextChannel _raceChannel;
|
private readonly ITextChannel _raceChannel;
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
private readonly CurrencyService _cs;
|
private readonly CurrencyService _cs;
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
private readonly ILocalization _localization;
|
private readonly ILocalization _localization;
|
||||||
@ -90,7 +89,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
|
|
||||||
public bool Started { get; private set; }
|
public bool Started { get; private set; }
|
||||||
|
|
||||||
public AnimalRace(ulong serverId, ITextChannel channel, string prefix, BotConfig bc,
|
public AnimalRace(ulong serverId, ITextChannel channel, string prefix, IBotConfigProvider bc,
|
||||||
CurrencyService cs, DiscordSocketClient client, ILocalization localization,
|
CurrencyService cs, DiscordSocketClient client, ILocalization localization,
|
||||||
NadekoStrings strings)
|
NadekoStrings strings)
|
||||||
{
|
{
|
||||||
@ -110,7 +109,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
animals = new ConcurrentQueue<string>(_bc.RaceAnimals.Select(ra => ra.Icon).Shuffle());
|
animals = new ConcurrentQueue<string>(_bc.BotConfig.RaceAnimals.Select(ra => ra.Icon).Shuffle());
|
||||||
|
|
||||||
|
|
||||||
var cancelSource = new CancellationTokenSource();
|
var cancelSource = new CancellationTokenSource();
|
||||||
@ -238,7 +237,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
await _raceChannel.SendConfirmAsync(GetText("animal_race"),
|
await _raceChannel.SendConfirmAsync(GetText("animal_race"),
|
||||||
Format.Bold(GetText("animal_race_won_money", winner.User.Mention,
|
Format.Bold(GetText("animal_race_won_money", winner.User.Mention,
|
||||||
winner.Animal, wonAmount + _bc.CurrencySign)))
|
winner.Animal, wonAmount + _bc.BotConfig.CurrencySign)))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -295,13 +294,13 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
if (amount > 0)
|
if (amount > 0)
|
||||||
if (!await _cs.RemoveAsync(u, "BetRace", amount, false).ConfigureAwait(false))
|
if (!await _cs.RemoveAsync(u, "BetRace", amount, false).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
await _raceChannel.SendErrorAsync(GetText("not_enough", _bc.CurrencySign)).ConfigureAwait(false);
|
await _raceChannel.SendErrorAsync(GetText("not_enough", _bc.BotConfig.CurrencySign)).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_participants.Add(p);
|
_participants.Add(p);
|
||||||
string confStr;
|
string confStr;
|
||||||
if (amount > 0)
|
if (amount > 0)
|
||||||
confStr = GetText("animal_race_join_bet", u.Mention, p.Animal, amount + _bc.CurrencySign);
|
confStr = GetText("animal_race_join_bet", u.Mention, p.Animal, amount + _bc.BotConfig.CurrencySign);
|
||||||
else
|
else
|
||||||
confStr = GetText("animal_race_join", u.Mention, p.Animal);
|
confStr = GetText("animal_race_join", u.Mention, p.Animal);
|
||||||
await _raceChannel.SendConfirmAsync(GetText("animal_race"), Format.Bold(confStr)).ConfigureAwait(false);
|
await _raceChannel.SendConfirmAsync(GetText("animal_race"), Format.Bold(confStr)).ConfigureAwait(false);
|
||||||
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NadekoBot.Common;
|
using NadekoBot.Common;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Gambling.Common
|
namespace NadekoBot.Modules.Gambling.Common
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,6 @@ using Discord.Commands;
|
|||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
@ -12,7 +11,6 @@ using NadekoBot.Common;
|
|||||||
using NadekoBot.Common.Attributes;
|
using NadekoBot.Common.Attributes;
|
||||||
using NadekoBot.Common.Collections;
|
using NadekoBot.Common.Collections;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NadekoBot.Services.Database.Models;
|
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Gambling
|
namespace NadekoBot.Modules.Gambling
|
||||||
{
|
{
|
||||||
@ -37,10 +35,10 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
|
|
||||||
private string _secretCode = string.Empty;
|
private string _secretCode = string.Empty;
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
private readonly CurrencyService _cs;
|
private readonly CurrencyService _cs;
|
||||||
|
|
||||||
public CurrencyEventsCommands(DiscordSocketClient client, BotConfig bc, CurrencyService cs)
|
public CurrencyEventsCommands(DiscordSocketClient client, IBotConfigProvider bc, CurrencyService cs)
|
||||||
{
|
{
|
||||||
_client = client;
|
_client = client;
|
||||||
_bc = bc;
|
_bc = bc;
|
||||||
@ -80,12 +78,12 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
_secretCode += _sneakyGameStatusChars[rng.Next(0, _sneakyGameStatusChars.Length)];
|
_secretCode += _sneakyGameStatusChars[rng.Next(0, _sneakyGameStatusChars.Length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
await _client.SetGameAsync($"type {_secretCode} for " + _bc.CurrencyPluralName)
|
await _client.SetGameAsync($"type {_secretCode} for " + _bc.BotConfig.CurrencyPluralName)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var title = GetText("sneakygamestatus_title");
|
var title = GetText("sneakygamestatus_title");
|
||||||
var desc = GetText("sneakygamestatus_desc", Format.Bold(100.ToString()) + _bc.CurrencySign, Format.Bold(num.ToString()));
|
var desc = GetText("sneakygamestatus_desc", Format.Bold(100.ToString()) + _bc.BotConfig.CurrencySign, Format.Bold(num.ToString()));
|
||||||
await context.Channel.SendConfirmAsync(title, desc).ConfigureAwait(false);
|
await context.Channel.SendConfirmAsync(title, desc).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@ -133,7 +131,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
amount = 100;
|
amount = 100;
|
||||||
|
|
||||||
var title = GetText("flowerreaction_title");
|
var title = GetText("flowerreaction_title");
|
||||||
var desc = GetText("flowerreaction_desc", "🌸", Format.Bold(amount.ToString()) + _bc.CurrencySign);
|
var desc = GetText("flowerreaction_desc", "🌸", Format.Bold(amount.ToString()) + _bc.BotConfig.CurrencySign);
|
||||||
var footer = GetText("flowerreaction_footer", 24);
|
var footer = GetText("flowerreaction_footer", 24);
|
||||||
var msg = await context.Channel.SendConfirmAsync(title,
|
var msg = await context.Channel.SendConfirmAsync(title,
|
||||||
desc, footer: footer)
|
desc, footer: footer)
|
||||||
|
@ -2,7 +2,6 @@ using Discord;
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using NadekoBot.Services.Database.Models;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -19,12 +18,12 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
public class FlipCoinCommands : NadekoSubmodule
|
public class FlipCoinCommands : NadekoSubmodule
|
||||||
{
|
{
|
||||||
private readonly IImagesService _images;
|
private readonly IImagesService _images;
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
private readonly CurrencyService _cs;
|
private readonly CurrencyService _cs;
|
||||||
|
|
||||||
private readonly NadekoRandom rng = new NadekoRandom();
|
private readonly NadekoRandom rng = new NadekoRandom();
|
||||||
|
|
||||||
public FlipCoinCommands(IImagesService images, CurrencyService cs, BotConfig bc)
|
public FlipCoinCommands(IImagesService images, CurrencyService cs, IBotConfigProvider bc)
|
||||||
{
|
{
|
||||||
_images = images;
|
_images = images;
|
||||||
_bc = bc;
|
_bc = bc;
|
||||||
@ -89,15 +88,15 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
public async Task Betflip(int amount, BetFlipGuess guess)
|
public async Task Betflip(int amount, BetFlipGuess guess)
|
||||||
{
|
{
|
||||||
if (amount < _bc.MinimumBetAmount)
|
if (amount < _bc.BotConfig.MinimumBetAmount)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalized("min_bet_limit", _bc.MinimumBetAmount + _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyErrorLocalized("min_bet_limit", _bc.BotConfig.MinimumBetAmount + _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var removed = await _cs.RemoveAsync(Context.User, "Betflip Gamble", amount, false).ConfigureAwait(false);
|
var removed = await _cs.RemoveAsync(Context.User, "Betflip Gamble", amount, false).ConfigureAwait(false);
|
||||||
if (!removed)
|
if (!removed)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalized("not_enough", _bc.CurrencyPluralName).ConfigureAwait(false);
|
await ReplyErrorLocalized("not_enough", _bc.BotConfig.CurrencyPluralName).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BetFlipGuess result;
|
BetFlipGuess result;
|
||||||
@ -116,8 +115,8 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
string str;
|
string str;
|
||||||
if (guess == result)
|
if (guess == result)
|
||||||
{
|
{
|
||||||
var toWin = (int)Math.Round(amount * _bc.BetflipMultiplier);
|
var toWin = (int)Math.Round(amount * _bc.BotConfig.BetflipMultiplier);
|
||||||
str = Context.User.Mention + " " + GetText("flip_guess", toWin + _bc.CurrencySign);
|
str = Context.User.Mention + " " + GetText("flip_guess", toWin + _bc.BotConfig.CurrencySign);
|
||||||
await _cs.AddAsync(Context.User, "Betflip Gamble", toWin, false).ConfigureAwait(false);
|
await _cs.AddAsync(Context.User, "Betflip Gamble", toWin, false).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -20,7 +20,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
[Group]
|
[Group]
|
||||||
public class FlowerShopCommands : NadekoSubmodule
|
public class FlowerShopCommands : NadekoSubmodule
|
||||||
{
|
{
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
private readonly CurrencyService _cs;
|
private readonly CurrencyService _cs;
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
@ -35,7 +35,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
List
|
List
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlowerShopCommands(BotConfig bc, DbService db, CurrencyService cs, DiscordSocketClient client)
|
public FlowerShopCommands(IBotConfigProvider bc, DbService db, CurrencyService cs, DiscordSocketClient client)
|
||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
_bc = bc;
|
_bc = bc;
|
||||||
@ -65,12 +65,12 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
return new EmbedBuilder().WithErrorColor()
|
return new EmbedBuilder().WithErrorColor()
|
||||||
.WithDescription(GetText("shop_none"));
|
.WithDescription(GetText("shop_none"));
|
||||||
var embed = new EmbedBuilder().WithOkColor()
|
var embed = new EmbedBuilder().WithOkColor()
|
||||||
.WithTitle(GetText("shop", _bc.CurrencySign));
|
.WithTitle(GetText("shop", _bc.BotConfig.CurrencySign));
|
||||||
|
|
||||||
for (int i = 0; i < theseEntries.Length; i++)
|
for (int i = 0; i < theseEntries.Length; i++)
|
||||||
{
|
{
|
||||||
var entry = entries[i];
|
var entry = entries[i];
|
||||||
embed.AddField(efb => efb.WithName($"#{curPage * 9 + i + 1} - {entry.Price}{_bc.CurrencySign}").WithValue(EntryToString(entry)).WithIsInline(true));
|
embed.AddField(efb => efb.WithName($"#{curPage * 9 + i + 1} - {entry.Price}{_bc.BotConfig.CurrencySign}").WithValue(EntryToString(entry)).WithIsInline(true));
|
||||||
}
|
}
|
||||||
return embed;
|
return embed;
|
||||||
}, entries.Count / 9, true);
|
}, entries.Count / 9, true);
|
||||||
@ -130,7 +130,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalized("not_enough", _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyErrorLocalized("not_enough", _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalized("not_enough", _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyErrorLocalized("not_enough", _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,15 +13,15 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
{
|
{
|
||||||
public partial class Gambling : NadekoTopLevelModule
|
public partial class Gambling : NadekoTopLevelModule
|
||||||
{
|
{
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
private readonly CurrencyService _currency;
|
private readonly CurrencyService _currency;
|
||||||
|
|
||||||
private string CurrencyName => _bc.CurrencyName;
|
private string CurrencyName => _bc.BotConfig.CurrencyName;
|
||||||
private string CurrencyPluralName => _bc.CurrencyPluralName;
|
private string CurrencyPluralName => _bc.BotConfig.CurrencyPluralName;
|
||||||
private string CurrencySign => _bc.CurrencySign;
|
private string CurrencySign => _bc.BotConfig.CurrencySign;
|
||||||
|
|
||||||
public Gambling(BotConfig bc, DbService db, CurrencyService currency)
|
public Gambling(IBotConfigProvider bc, DbService db, CurrencyService currency)
|
||||||
{
|
{
|
||||||
_bc = bc;
|
_bc = bc;
|
||||||
_db = db;
|
_db = db;
|
||||||
@ -230,21 +230,21 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
{
|
{
|
||||||
if (rnd < 91)
|
if (rnd < 91)
|
||||||
{
|
{
|
||||||
str += GetText("br_win", (amount * _bc.Betroll67Multiplier) + CurrencySign, 66);
|
str += GetText("br_win", (amount * _bc.BotConfig.Betroll67Multiplier) + CurrencySign, 66);
|
||||||
await _currency.AddAsync(Context.User, "Betroll Gamble",
|
await _currency.AddAsync(Context.User, "Betroll Gamble",
|
||||||
(int) (amount * _bc.Betroll67Multiplier), false).ConfigureAwait(false);
|
(int) (amount * _bc.BotConfig.Betroll67Multiplier), false).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else if (rnd < 100)
|
else if (rnd < 100)
|
||||||
{
|
{
|
||||||
str += GetText("br_win", (amount * _bc.Betroll91Multiplier) + CurrencySign, 90);
|
str += GetText("br_win", (amount * _bc.BotConfig.Betroll91Multiplier) + CurrencySign, 90);
|
||||||
await _currency.AddAsync(Context.User, "Betroll Gamble",
|
await _currency.AddAsync(Context.User, "Betroll Gamble",
|
||||||
(int) (amount * _bc.Betroll91Multiplier), false).ConfigureAwait(false);
|
(int) (amount * _bc.BotConfig.Betroll91Multiplier), false).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
str += GetText("br_win", (amount * _bc.Betroll100Multiplier) + CurrencySign, 100) + " 👑";
|
str += GetText("br_win", (amount * _bc.BotConfig.Betroll100Multiplier) + CurrencySign, 100) + " 👑";
|
||||||
await _currency.AddAsync(Context.User, "Betroll Gamble",
|
await _currency.AddAsync(Context.User, "Betroll Gamble",
|
||||||
(int) (amount * _bc.Betroll100Multiplier), false).ConfigureAwait(false);
|
(int) (amount * _bc.BotConfig.Betroll100Multiplier), false).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await Context.Channel.SendConfirmAsync(str).ConfigureAwait(false);
|
await Context.Channel.SendConfirmAsync(str).ConfigureAwait(false);
|
||||||
|
@ -3,7 +3,6 @@ using Discord.Commands;
|
|||||||
using ImageSharp;
|
using ImageSharp;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using NadekoBot.Services.Database.Models;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -25,7 +24,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
private static int _totalPaidOut;
|
private static int _totalPaidOut;
|
||||||
|
|
||||||
private static readonly HashSet<ulong> _runningUsers = new HashSet<ulong>();
|
private static readonly HashSet<ulong> _runningUsers = new HashSet<ulong>();
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
|
|
||||||
private const int _alphaCutOut = byte.MaxValue / 3;
|
private const int _alphaCutOut = byte.MaxValue / 3;
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
private readonly IImagesService _images;
|
private readonly IImagesService _images;
|
||||||
private readonly CurrencyService _cs;
|
private readonly CurrencyService _cs;
|
||||||
|
|
||||||
public SlotCommands(IImagesService images, BotConfig bc, CurrencyService cs)
|
public SlotCommands(IImagesService images, IBotConfigProvider bc, CurrencyService cs)
|
||||||
{
|
{
|
||||||
_images = images;
|
_images = images;
|
||||||
_bc = bc;
|
_bc = bc;
|
||||||
@ -148,20 +147,20 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
{
|
{
|
||||||
if (amount < 1)
|
if (amount < 1)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalized("min_bet_limit", 1 + _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyErrorLocalized("min_bet_limit", 1 + _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const int maxAmount = 9999;
|
const int maxAmount = 9999;
|
||||||
if (amount > maxAmount)
|
if (amount > maxAmount)
|
||||||
{
|
{
|
||||||
GetText("slot_maxbet", maxAmount + _bc.CurrencySign);
|
GetText("slot_maxbet", maxAmount + _bc.BotConfig.CurrencySign);
|
||||||
await ReplyErrorLocalized("max_bet_limit", maxAmount + _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyErrorLocalized("max_bet_limit", maxAmount + _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!await _cs.RemoveAsync(Context.User, "Slot Machine", amount, false))
|
if (!await _cs.RemoveAsync(Context.User, "Slot Machine", amount, false))
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalized("not_enough", _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyErrorLocalized("not_enough", _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Interlocked.Add(ref _totalBet, amount);
|
Interlocked.Add(ref _totalBet, amount);
|
||||||
@ -202,7 +201,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
var digit = printAmount % 10;
|
var digit = printAmount % 10;
|
||||||
using (var fs = _images.SlotNumbers[digit].ToStream())
|
using (var fs = _images.SlotNumbers[digit].ToStream())
|
||||||
using (var img = ImageSharp.Image.Load(fs))
|
using (var img = ImageSharp.Image.Load(fs))
|
||||||
{
|
{
|
||||||
bgImage.DrawImage(img, 100, default(Size), new Point(395 - n * 16, 462));
|
bgImage.DrawImage(img, 100, default(Size), new Point(395 - n * 16, 462));
|
||||||
}
|
}
|
||||||
n++;
|
n++;
|
||||||
@ -214,16 +213,16 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
await _cs.AddAsync(Context.User, $"Slot Machine x{result.Multiplier}", amount * result.Multiplier, false);
|
await _cs.AddAsync(Context.User, $"Slot Machine x{result.Multiplier}", amount * result.Multiplier, false);
|
||||||
Interlocked.Add(ref _totalPaidOut, amount * result.Multiplier);
|
Interlocked.Add(ref _totalPaidOut, amount * result.Multiplier);
|
||||||
if (result.Multiplier == 1)
|
if (result.Multiplier == 1)
|
||||||
msg = GetText("slot_single", _bc.CurrencySign, 1);
|
msg = GetText("slot_single", _bc.BotConfig.CurrencySign, 1);
|
||||||
else if (result.Multiplier == 4)
|
else if (result.Multiplier == 4)
|
||||||
msg = GetText("slot_two", _bc.CurrencySign, 4);
|
msg = GetText("slot_two", _bc.BotConfig.CurrencySign, 4);
|
||||||
else if (result.Multiplier == 10)
|
else if (result.Multiplier == 10)
|
||||||
msg = GetText("slot_three", 10);
|
msg = GetText("slot_three", 10);
|
||||||
else if (result.Multiplier == 30)
|
else if (result.Multiplier == 30)
|
||||||
msg = GetText("slot_jackpot", 30);
|
msg = GetText("slot_jackpot", 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Context.Channel.SendFileAsync(bgImage.ToStream(), "result.png", Context.User.Mention + " " + msg + $"\n`{GetText("slot_bet")}:`{amount} `{GetText("slot_won")}:` {amount * result.Multiplier}{_bc.CurrencySign}").ConfigureAwait(false);
|
await Context.Channel.SendFileAsync(bgImage.ToStream(), "result.png", Context.User.Mention + " " + msg + $"\n`{GetText("slot_bet")}:`{amount} `{GetText("slot_won")}:` {amount * result.Multiplier}{_bc.BotConfig.CurrencySign}").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -58,7 +58,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
InsufficientAmount
|
InsufficientAmount
|
||||||
}
|
}
|
||||||
|
|
||||||
public WaifuClaimCommands(BotConfig bc, CurrencyService cs, DbService db)
|
public WaifuClaimCommands(IBotConfigProvider bc, CurrencyService cs, DbService db)
|
||||||
{
|
{
|
||||||
_bc = bc;
|
_bc = bc;
|
||||||
_cs = cs;
|
_cs = cs;
|
||||||
@ -71,7 +71,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
{
|
{
|
||||||
if (amount < 50)
|
if (amount < 50)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalized("waifu_isnt_cheap", 50 + _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyErrorLocalized("waifu_isnt_cheap", 50 + _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,14 +173,14 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
}
|
}
|
||||||
if (result == WaifuClaimResult.NotEnoughFunds)
|
if (result == WaifuClaimResult.NotEnoughFunds)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalized("not_enough", _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyErrorLocalized("not_enough", _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var msg = GetText("waifu_claimed",
|
var msg = GetText("waifu_claimed",
|
||||||
Format.Bold(target.ToString()),
|
Format.Bold(target.ToString()),
|
||||||
amount + _bc.CurrencySign);
|
amount + _bc.BotConfig.CurrencySign);
|
||||||
if (w.Affinity?.UserId == Context.User.Id)
|
if (w.Affinity?.UserId == Context.User.Id)
|
||||||
msg += "\n" + GetText("waifu_fulfilled", target, w.Price + _bc.CurrencySign);
|
msg += "\n" + GetText("waifu_fulfilled", target, w.Price + _bc.BotConfig.CurrencySign);
|
||||||
else
|
else
|
||||||
msg = " " + msg;
|
msg = " " + msg;
|
||||||
await Context.Channel.SendConfirmAsync(Context.User.Mention + msg).ConfigureAwait(false);
|
await Context.Channel.SendConfirmAsync(Context.User.Mention + msg).ConfigureAwait(false);
|
||||||
@ -258,11 +258,11 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
|
|
||||||
if (result == DivorceResult.SucessWithPenalty)
|
if (result == DivorceResult.SucessWithPenalty)
|
||||||
{
|
{
|
||||||
await ReplyConfirmLocalized("waifu_divorced_like", Format.Bold(w.Waifu.ToString()), amount + _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyConfirmLocalized("waifu_divorced_like", Format.Bold(w.Waifu.ToString()), amount + _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else if (result == DivorceResult.Success)
|
else if (result == DivorceResult.Success)
|
||||||
{
|
{
|
||||||
await ReplyConfirmLocalized("waifu_divorced_notlike", amount + _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyConfirmLocalized("waifu_divorced_notlike", amount + _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else if (result == DivorceResult.NotYourWife)
|
else if (result == DivorceResult.NotYourWife)
|
||||||
{
|
{
|
||||||
@ -278,7 +278,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static readonly TimeSpan _affinityLimit = TimeSpan.FromMinutes(30);
|
private static readonly TimeSpan _affinityLimit = TimeSpan.FromMinutes(30);
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
private readonly CurrencyService _cs;
|
private readonly CurrencyService _cs;
|
||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
|
|
||||||
@ -406,7 +406,7 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
var w = waifus[i];
|
var w = waifus[i];
|
||||||
|
|
||||||
var j = i;
|
var j = i;
|
||||||
embed.AddField(efb => efb.WithName("#" + ((page * 9) + j + 1) + " - " + w.Price + _bc.CurrencySign).WithValue(w.ToString()).WithIsInline(false));
|
embed.AddField(efb => efb.WithName("#" + ((page * 9) + j + 1) + " - " + w.Price + _bc.BotConfig.CurrencySign).WithValue(w.ToString()).WithIsInline(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
|
||||||
using NLog;
|
using NLog;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NadekoBot.Common;
|
using NadekoBot.Common;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Games.Common
|
namespace NadekoBot.Modules.Games.Common
|
||||||
|
@ -7,7 +7,6 @@ using Discord;
|
|||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NadekoBot.Common;
|
using NadekoBot.Common;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ using System.Threading.Tasks;
|
|||||||
using Discord;
|
using Discord;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
|
||||||
using NadekoBot.Services.Impl;
|
using NadekoBot.Services.Impl;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Games.Common
|
namespace NadekoBot.Modules.Games.Common
|
||||||
|
@ -10,7 +10,6 @@ using Discord.Net;
|
|||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using NadekoBot.Services.Database.Models;
|
|
||||||
using NadekoBot.Services.Impl;
|
using NadekoBot.Services.Impl;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
|
|||||||
private readonly Logger _log;
|
private readonly Logger _log;
|
||||||
private readonly NadekoStrings _strings;
|
private readonly NadekoStrings _strings;
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
private readonly CurrencyService _cs;
|
private readonly CurrencyService _cs;
|
||||||
|
|
||||||
public IGuild Guild { get; }
|
public IGuild Guild { get; }
|
||||||
@ -44,7 +43,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
|
|||||||
|
|
||||||
public int WinRequirement { get; }
|
public int WinRequirement { get; }
|
||||||
|
|
||||||
public TriviaGame(NadekoStrings strings, DiscordSocketClient client, BotConfig bc,
|
public TriviaGame(NadekoStrings strings, DiscordSocketClient client, IBotConfigProvider bc,
|
||||||
CurrencyService cs, IGuild guild, ITextChannel channel,
|
CurrencyService cs, IGuild guild, ITextChannel channel,
|
||||||
bool showHints, int winReq, bool isPokemon)
|
bool showHints, int winReq, bool isPokemon)
|
||||||
{
|
{
|
||||||
@ -232,7 +231,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
|
|||||||
{
|
{
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
var reward = _bc.TriviaCurrencyReward;
|
var reward = _bc.BotConfig.TriviaCurrencyReward;
|
||||||
if (reward > 0)
|
if (reward > 0)
|
||||||
await _cs.AddAsync(guildUser, "Won trivia", reward, true).ConfigureAwait(false);
|
await _cs.AddAsync(guildUser, "Won trivia", reward, true).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
|
@ -5,7 +5,6 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NadekoBot.Common;
|
using NadekoBot.Common;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Games.Common.Trivia
|
namespace NadekoBot.Modules.Games.Common.Trivia
|
||||||
|
@ -8,7 +8,6 @@ using Discord.WebSocket;
|
|||||||
using NadekoBot.Common;
|
using NadekoBot.Common;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Modules.Games.Services;
|
using NadekoBot.Modules.Games.Services;
|
||||||
using NadekoBot.Services;
|
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Games.Common
|
namespace NadekoBot.Modules.Games.Common
|
||||||
|
@ -25,11 +25,11 @@ namespace NadekoBot.Modules.Games
|
|||||||
public class PlantPickCommands : NadekoSubmodule
|
public class PlantPickCommands : NadekoSubmodule
|
||||||
{
|
{
|
||||||
private readonly CurrencyService _cs;
|
private readonly CurrencyService _cs;
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
private readonly GamesService _games;
|
private readonly GamesService _games;
|
||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
|
|
||||||
public PlantPickCommands(BotConfig bc, CurrencyService cs, GamesService games,
|
public PlantPickCommands(IBotConfigProvider bc, CurrencyService cs, GamesService games,
|
||||||
DbService db)
|
DbService db)
|
||||||
{
|
{
|
||||||
_bc = bc;
|
_bc = bc;
|
||||||
@ -54,8 +54,8 @@ namespace NadekoBot.Modules.Games
|
|||||||
|
|
||||||
await Task.WhenAll(msgs.Where(m => m != null).Select(toDelete => toDelete.DeleteAsync())).ConfigureAwait(false);
|
await Task.WhenAll(msgs.Where(m => m != null).Select(toDelete => toDelete.DeleteAsync())).ConfigureAwait(false);
|
||||||
|
|
||||||
await _cs.AddAsync((IGuildUser)Context.User, $"Picked {_bc.CurrencyPluralName}", msgs.Count, false).ConfigureAwait(false);
|
await _cs.AddAsync((IGuildUser)Context.User, $"Picked {_bc.BotConfig.CurrencyPluralName}", msgs.Count, false).ConfigureAwait(false);
|
||||||
var msg = await ReplyConfirmLocalized("picked", msgs.Count + _bc.CurrencySign)
|
var msg = await ReplyConfirmLocalized("picked", msgs.Count + _bc.BotConfig.CurrencySign)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
msg.DeleteAfter(10);
|
msg.DeleteAfter(10);
|
||||||
}
|
}
|
||||||
@ -67,10 +67,10 @@ namespace NadekoBot.Modules.Games
|
|||||||
if (amount < 1)
|
if (amount < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var removed = await _cs.RemoveAsync((IGuildUser)Context.User, $"Planted a {_bc.CurrencyName}", amount, false).ConfigureAwait(false);
|
var removed = await _cs.RemoveAsync((IGuildUser)Context.User, $"Planted a {_bc.BotConfig.CurrencyName}", amount, false).ConfigureAwait(false);
|
||||||
if (!removed)
|
if (!removed)
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalized("not_enough", _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyErrorLocalized("not_enough", _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
//todo 81 upload all currency images to transfer.sh and use that one as cdn
|
//todo 81 upload all currency images to transfer.sh and use that one as cdn
|
||||||
var msgToSend = GetText("planted",
|
var msgToSend = GetText("planted",
|
||||||
Format.Bold(Context.User.ToString()),
|
Format.Bold(Context.User.ToString()),
|
||||||
amount + _bc.CurrencySign,
|
amount + _bc.BotConfig.CurrencySign,
|
||||||
Prefix);
|
Prefix);
|
||||||
|
|
||||||
if (amount > 1)
|
if (amount > 1)
|
||||||
|
@ -22,7 +22,7 @@ namespace NadekoBot.Modules.Games.Services
|
|||||||
{
|
{
|
||||||
public class GamesService : INService
|
public class GamesService : INService
|
||||||
{
|
{
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
|
|
||||||
public readonly ConcurrentDictionary<ulong, GirlRating> GirlRatings = new ConcurrentDictionary<ulong, GirlRating>();
|
public readonly ConcurrentDictionary<ulong, GirlRating> GirlRatings = new ConcurrentDictionary<ulong, GirlRating>();
|
||||||
public readonly ImmutableArray<string> EightBallResponses;
|
public readonly ImmutableArray<string> EightBallResponses;
|
||||||
@ -38,7 +38,7 @@ namespace NadekoBot.Modules.Games.Services
|
|||||||
|
|
||||||
public List<TypingArticle> TypingArticles { get; } = new List<TypingArticle>();
|
public List<TypingArticle> TypingArticles { get; } = new List<TypingArticle>();
|
||||||
|
|
||||||
public GamesService(DiscordSocketClient client, BotConfig bc, IEnumerable<GuildConfig> gcs,
|
public GamesService(DiscordSocketClient client, IBotConfigProvider bc, IEnumerable<GuildConfig> gcs,
|
||||||
NadekoStrings strings, IImagesService images, CommandHandler cmdHandler)
|
NadekoStrings strings, IImagesService images, CommandHandler cmdHandler)
|
||||||
{
|
{
|
||||||
_bc = bc;
|
_bc = bc;
|
||||||
@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Games.Services
|
|||||||
_log = LogManager.GetCurrentClassLogger();
|
_log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
//8ball
|
//8ball
|
||||||
EightBallResponses = _bc.EightBallResponses.Select(ebr => ebr.Text).ToImmutableArray();
|
EightBallResponses = _bc.BotConfig.EightBallResponses.Select(ebr => ebr.Text).ToImmutableArray();
|
||||||
|
|
||||||
//girl ratings
|
//girl ratings
|
||||||
_t = new Timer((_) =>
|
_t = new Timer((_) =>
|
||||||
@ -122,14 +122,14 @@ namespace NadekoBot.Modules.Games.Services
|
|||||||
var lastGeneration = LastGenerations.GetOrAdd(channel.Id, DateTime.MinValue);
|
var lastGeneration = LastGenerations.GetOrAdd(channel.Id, DateTime.MinValue);
|
||||||
var rng = new NadekoRandom();
|
var rng = new NadekoRandom();
|
||||||
|
|
||||||
if (DateTime.UtcNow - TimeSpan.FromSeconds(_bc.CurrencyGenerationCooldown) < lastGeneration) //recently generated in this channel, don't generate again
|
if (DateTime.UtcNow - TimeSpan.FromSeconds(_bc.BotConfig.CurrencyGenerationCooldown) < lastGeneration) //recently generated in this channel, don't generate again
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var num = rng.Next(1, 101) + _bc.CurrencyGenerationChance * 100;
|
var num = rng.Next(1, 101) + _bc.BotConfig.CurrencyGenerationChance * 100;
|
||||||
if (num > 100 && LastGenerations.TryUpdate(channel.Id, DateTime.UtcNow, lastGeneration))
|
if (num > 100 && LastGenerations.TryUpdate(channel.Id, DateTime.UtcNow, lastGeneration))
|
||||||
{
|
{
|
||||||
var dropAmount = _bc.CurrencyDropAmount;
|
var dropAmount = _bc.BotConfig.CurrencyDropAmount;
|
||||||
var dropAmountMax = _bc.CurrencyDropAmountMax;
|
var dropAmountMax = _bc.BotConfig.CurrencyDropAmountMax;
|
||||||
|
|
||||||
if (dropAmountMax != null && dropAmountMax > dropAmount)
|
if (dropAmountMax != null && dropAmountMax > dropAmount)
|
||||||
dropAmount = new NadekoRandom().Next(dropAmount, dropAmountMax.Value + 1);
|
dropAmount = new NadekoRandom().Next(dropAmount, dropAmountMax.Value + 1);
|
||||||
@ -139,9 +139,9 @@ namespace NadekoBot.Modules.Games.Services
|
|||||||
var msgs = new IUserMessage[dropAmount];
|
var msgs = new IUserMessage[dropAmount];
|
||||||
var prefix = _cmdHandler.GetPrefix(channel.Guild.Id);
|
var prefix = _cmdHandler.GetPrefix(channel.Guild.Id);
|
||||||
var toSend = dropAmount == 1
|
var toSend = dropAmount == 1
|
||||||
? GetText(channel, "curgen_sn", _bc.CurrencySign)
|
? GetText(channel, "curgen_sn", _bc.BotConfig.CurrencySign)
|
||||||
+ " " + GetText(channel, "pick_sn", prefix)
|
+ " " + GetText(channel, "pick_sn", prefix)
|
||||||
: GetText(channel, "curgen_pl", dropAmount, _bc.CurrencySign)
|
: GetText(channel, "curgen_pl", dropAmount, _bc.BotConfig.CurrencySign)
|
||||||
+ " " + GetText(channel, "pick_pl", prefix);
|
+ " " + GetText(channel, "pick_pl", prefix);
|
||||||
var file = GetRandomCurrencyImage();
|
var file = GetRandomCurrencyImage();
|
||||||
using (var fileStream = file.Data.ToStream())
|
using (var fileStream = file.Data.ToStream())
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -3,13 +3,11 @@ using Discord.Commands;
|
|||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using NadekoBot.Services.Database.Models;
|
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NadekoBot.Common.Attributes;
|
using NadekoBot.Common.Attributes;
|
||||||
using NadekoBot.Modules.Games.Common.Trivia;
|
using NadekoBot.Modules.Games.Common.Trivia;
|
||||||
|
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Games
|
namespace NadekoBot.Modules.Games
|
||||||
{
|
{
|
||||||
public partial class Games
|
public partial class Games
|
||||||
@ -19,11 +17,11 @@ namespace NadekoBot.Modules.Games
|
|||||||
{
|
{
|
||||||
private readonly CurrencyService _cs;
|
private readonly CurrencyService _cs;
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
|
|
||||||
public static ConcurrentDictionary<ulong, TriviaGame> RunningTrivias { get; } = new ConcurrentDictionary<ulong, TriviaGame>();
|
public static ConcurrentDictionary<ulong, TriviaGame> RunningTrivias { get; } = new ConcurrentDictionary<ulong, TriviaGame>();
|
||||||
|
|
||||||
public TriviaCommands(DiscordSocketClient client, BotConfig bc, CurrencyService cs)
|
public TriviaCommands(DiscordSocketClient client, IBotConfigProvider bc, CurrencyService cs)
|
||||||
{
|
{
|
||||||
_cs = cs;
|
_cs = cs;
|
||||||
_client = client;
|
_client = client;
|
||||||
|
@ -9,7 +9,6 @@ using System.IO;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NadekoBot.Common.Attributes;
|
using NadekoBot.Common.Attributes;
|
||||||
using NadekoBot.Services.Database.Models;
|
|
||||||
using NadekoBot.Modules.Help.Services;
|
using NadekoBot.Modules.Help.Services;
|
||||||
using NadekoBot.Modules.Permissions.Services;
|
using NadekoBot.Modules.Permissions.Services;
|
||||||
|
|
||||||
@ -20,14 +19,14 @@ namespace NadekoBot.Modules.Help
|
|||||||
public const string PatreonUrl = "https://patreon.com/nadekobot";
|
public const string PatreonUrl = "https://patreon.com/nadekobot";
|
||||||
public const string PaypalUrl = "https://paypal.me/Kwoth";
|
public const string PaypalUrl = "https://paypal.me/Kwoth";
|
||||||
private readonly IBotCredentials _creds;
|
private readonly IBotCredentials _creds;
|
||||||
private readonly BotConfig _config;
|
private readonly IBotConfigProvider _config;
|
||||||
private readonly CommandService _cmds;
|
private readonly CommandService _cmds;
|
||||||
private readonly GlobalPermissionService _perms;
|
private readonly GlobalPermissionService _perms;
|
||||||
|
|
||||||
public string HelpString => String.Format(_config.HelpString, _creds.ClientId, Prefix);
|
public string HelpString => String.Format(_config.BotConfig.HelpString, _creds.ClientId, Prefix);
|
||||||
public string DMHelpString => _config.DMHelpString;
|
public string DMHelpString => _config.BotConfig.DMHelpString;
|
||||||
|
|
||||||
public Help(IBotCredentials creds, GlobalPermissionService perms, BotConfig config, CommandService cmds)
|
public Help(IBotCredentials creds, GlobalPermissionService perms, IBotConfigProvider config, CommandService cmds)
|
||||||
{
|
{
|
||||||
_creds = creds;
|
_creds = creds;
|
||||||
_config = config;
|
_config = config;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using NadekoBot.Services.Database.Models;
|
using System.Threading.Tasks;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using System;
|
using System;
|
||||||
@ -15,11 +14,11 @@ namespace NadekoBot.Modules.Help.Services
|
|||||||
{
|
{
|
||||||
public class HelpService : ILateExecutor, INService
|
public class HelpService : ILateExecutor, INService
|
||||||
{
|
{
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
private readonly CommandHandler _ch;
|
private readonly CommandHandler _ch;
|
||||||
private readonly NadekoStrings _strings;
|
private readonly NadekoStrings _strings;
|
||||||
|
|
||||||
public HelpService(BotConfig bc, CommandHandler ch, NadekoStrings strings)
|
public HelpService(IBotConfigProvider bc, CommandHandler ch, NadekoStrings strings)
|
||||||
{
|
{
|
||||||
_bc = bc;
|
_bc = bc;
|
||||||
_ch = ch;
|
_ch = ch;
|
||||||
@ -31,7 +30,7 @@ namespace NadekoBot.Modules.Help.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(guild == null)
|
if(guild == null)
|
||||||
await msg.Channel.SendMessageAsync(_bc.DMHelpString).ConfigureAwait(false);
|
await msg.Channel.SendMessageAsync(_bc.BotConfig.DMHelpString).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
@ -2,13 +2,8 @@
|
|||||||
|
|
||||||
namespace NadekoBot.Modules.Music.Common.Exceptions
|
namespace NadekoBot.Modules.Music.Common.Exceptions
|
||||||
{
|
{
|
||||||
// todo use this
|
|
||||||
public class NotInVoiceChannelException : Exception
|
public class NotInVoiceChannelException : Exception
|
||||||
{
|
{
|
||||||
public NotInVoiceChannelException(string message) : base(message)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotInVoiceChannelException() : base("You're not in the voice channel on this server.") { }
|
public NotInVoiceChannelException() : base("You're not in the voice channel on this server.") { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NLog;
|
using NLog;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using NadekoBot.Common.Collections;
|
using NadekoBot.Common.Collections;
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Modules.Music.Common.Exceptions;
|
using NadekoBot.Modules.Music.Common.Exceptions;
|
||||||
using NadekoBot.Services;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NadekoBot.Common;
|
using NadekoBot.Common;
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ using System.Linq;
|
|||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using NadekoBot.Common;
|
using NadekoBot.Common;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord;
|
using Discord;
|
||||||
@ -88,7 +87,7 @@ namespace NadekoBot.Modules.Music.Services
|
|||||||
{
|
{
|
||||||
await textCh.SendErrorAsync(GetText("must_be_in_voice")).ConfigureAwait(false);
|
await textCh.SendErrorAsync(GetText("must_be_in_voice")).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
throw new ArgumentException(nameof(voiceCh));
|
throw new NotInVoiceChannelException();
|
||||||
}
|
}
|
||||||
_log.Info("Get or add");
|
_log.Info("Get or add");
|
||||||
return MusicPlayers.GetOrAdd(guildId, _ =>
|
return MusicPlayers.GetOrAdd(guildId, _ =>
|
||||||
|
@ -4,7 +4,6 @@ using Newtonsoft.Json.Linq;
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NadekoBot.Services;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -5,7 +5,6 @@ using NadekoBot.Services;
|
|||||||
using NLog;
|
using NLog;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System;
|
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NadekoBot.Services.Impl;
|
using NadekoBot.Services.Impl;
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NadekoBot.Common;
|
|
||||||
using NadekoBot.Common.Collections;
|
using NadekoBot.Common.Collections;
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ using Discord.WebSocket;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NadekoBot.Common.Attributes;
|
using NadekoBot.Common.Attributes;
|
||||||
|
@ -7,7 +7,6 @@ using Discord;
|
|||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NadekoBot.Common;
|
|
||||||
using NadekoBot.Common.Attributes;
|
using NadekoBot.Common.Attributes;
|
||||||
using NadekoBot.Common.TypeReaders;
|
using NadekoBot.Common.TypeReaders;
|
||||||
using NadekoBot.Common.TypeReaders.Models;
|
using NadekoBot.Common.TypeReaders.Models;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NadekoBot.Services;
|
|
||||||
using NadekoBot.Services.Database.Models;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NadekoBot.Common.Attributes;
|
using NadekoBot.Common.Attributes;
|
||||||
using NadekoBot.Modules.Permissions.Services;
|
using NadekoBot.Modules.Permissions.Services;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord;
|
using Discord;
|
||||||
using NadekoBot.Common.Collections;
|
using NadekoBot.Common.Collections;
|
||||||
@ -15,9 +14,9 @@ namespace NadekoBot.Modules.Permissions.Services
|
|||||||
public ConcurrentHashSet<ulong> BlacklistedGuilds { get; }
|
public ConcurrentHashSet<ulong> BlacklistedGuilds { get; }
|
||||||
public ConcurrentHashSet<ulong> BlacklistedChannels { get; }
|
public ConcurrentHashSet<ulong> BlacklistedChannels { get; }
|
||||||
|
|
||||||
public BlacklistService(BotConfig bc)
|
public BlacklistService(IBotConfigProvider bc)
|
||||||
{
|
{
|
||||||
var blacklist = bc.Blacklist;
|
var blacklist = bc.BotConfig.Blacklist;
|
||||||
BlacklistedUsers = new ConcurrentHashSet<ulong>(blacklist.Where(bi => bi.Type == BlacklistType.User).Select(c => c.ItemId));
|
BlacklistedUsers = new ConcurrentHashSet<ulong>(blacklist.Where(bi => bi.Type == BlacklistType.User).Select(c => c.ItemId));
|
||||||
BlacklistedGuilds = new ConcurrentHashSet<ulong>(blacklist.Where(bi => bi.Type == BlacklistType.Server).Select(c => c.ItemId));
|
BlacklistedGuilds = new ConcurrentHashSet<ulong>(blacklist.Where(bi => bi.Type == BlacklistType.Server).Select(c => c.ItemId));
|
||||||
BlacklistedChannels = new ConcurrentHashSet<ulong>(blacklist.Where(bi => bi.Type == BlacklistType.Channel).Select(c => c.ItemId));
|
BlacklistedChannels = new ConcurrentHashSet<ulong>(blacklist.Where(bi => bi.Type == BlacklistType.Channel).Select(c => c.ItemId));
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using NadekoBot.Common.Collections;
|
using NadekoBot.Common.Collections;
|
||||||
using NadekoBot.Common.ModuleBehaviors;
|
using NadekoBot.Common.ModuleBehaviors;
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using NadekoBot.Services.Database.Models;
|
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Permissions.Services
|
namespace NadekoBot.Modules.Permissions.Services
|
||||||
{
|
{
|
||||||
@ -15,10 +13,10 @@ namespace NadekoBot.Modules.Permissions.Services
|
|||||||
public readonly ConcurrentHashSet<string> BlockedModules;
|
public readonly ConcurrentHashSet<string> BlockedModules;
|
||||||
public readonly ConcurrentHashSet<string> BlockedCommands;
|
public readonly ConcurrentHashSet<string> BlockedCommands;
|
||||||
|
|
||||||
public GlobalPermissionService(BotConfig bc)
|
public GlobalPermissionService(IBotConfigProvider bc)
|
||||||
{
|
{
|
||||||
BlockedModules = new ConcurrentHashSet<string>(bc.BlockedModules.Select(x => x.Name));
|
BlockedModules = new ConcurrentHashSet<string>(bc.BotConfig.BlockedModules.Select(x => x.Name));
|
||||||
BlockedCommands = new ConcurrentHashSet<string>(bc.BlockedCommands.Select(x => x.Name));
|
BlockedCommands = new ConcurrentHashSet<string>(bc.BotConfig.BlockedCommands.Select(x => x.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> TryBlockLate(DiscordSocketClient client, IUserMessage msg, IGuild guild, IMessageChannel channel, IUser user, string moduleName, string commandName)
|
public async Task<bool> TryBlockLate(DiscordSocketClient client, IUserMessage msg, IGuild guild, IMessageChannel channel, IUser user, string moduleName, string commandName)
|
||||||
|
@ -16,10 +16,10 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
public class Pokemon : NadekoTopLevelModule<PokemonService>
|
public class Pokemon : NadekoTopLevelModule<PokemonService>
|
||||||
{
|
{
|
||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
private readonly BotConfig _bc;
|
private readonly IBotConfigProvider _bc;
|
||||||
private readonly CurrencyService _cs;
|
private readonly CurrencyService _cs;
|
||||||
|
|
||||||
public Pokemon(DbService db, BotConfig bc, CurrencyService cs)
|
public Pokemon(DbService db, IBotConfigProvider bc, CurrencyService cs)
|
||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
_bc = bc;
|
_bc = bc;
|
||||||
@ -230,7 +230,7 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
{
|
{
|
||||||
if (!await _cs.RemoveAsync(user, $"Poke-Heal {target}", amount, true).ConfigureAwait(false))
|
if (!await _cs.RemoveAsync(user, $"Poke-Heal {target}", amount, true).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalized("no_currency", _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyErrorLocalized("no_currency", _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,13 +243,13 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
_service.Stats[targetUser.Id].Hp = (targetStats.MaxHp / 2);
|
_service.Stats[targetUser.Id].Hp = (targetStats.MaxHp / 2);
|
||||||
if (target == "yourself")
|
if (target == "yourself")
|
||||||
{
|
{
|
||||||
await ReplyConfirmLocalized("revive_yourself", _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyConfirmLocalized("revive_yourself", _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await ReplyConfirmLocalized("revive_other", Format.Bold(targetUser.ToString()), _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyConfirmLocalized("revive_other", Format.Bold(targetUser.ToString()), _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await ReplyConfirmLocalized("healed", Format.Bold(targetUser.ToString()), _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyConfirmLocalized("healed", Format.Bold(targetUser.ToString()), _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -296,7 +296,7 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
{
|
{
|
||||||
if (!await _cs.RemoveAsync(user, $"{user} change type to {typeTargeted}", amount, true).ConfigureAwait(false))
|
if (!await _cs.RemoveAsync(user, $"{user} change type to {typeTargeted}", amount, true).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
await ReplyErrorLocalized("no_currency", _bc.CurrencySign).ConfigureAwait(false);
|
await ReplyErrorLocalized("no_currency", _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -330,7 +330,7 @@ namespace NadekoBot.Modules.Pokemon
|
|||||||
//Now for the response
|
//Now for the response
|
||||||
await ReplyConfirmLocalized("settype_success",
|
await ReplyConfirmLocalized("settype_success",
|
||||||
targetType,
|
targetType,
|
||||||
_bc.CurrencySign).ConfigureAwait(false);
|
_bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ using System.Threading.Tasks;
|
|||||||
using System.Xml;
|
using System.Xml;
|
||||||
using NadekoBot.Common;
|
using NadekoBot.Common;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Modules.Searches.Services;
|
using NadekoBot.Modules.Searches.Services;
|
||||||
using NadekoBot.Services;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NadekoBot.Common;
|
using NadekoBot.Common;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
39
src/NadekoBot/Modules/Utility/BotConfigCommands.cs
Normal file
39
src/NadekoBot/Modules/Utility/BotConfigCommands.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using Discord;
|
||||||
|
using Discord.Commands;
|
||||||
|
using NadekoBot.Common;
|
||||||
|
using NadekoBot.Common.Attributes;
|
||||||
|
using NadekoBot.Services;
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace NadekoBot.Modules.Utility
|
||||||
|
{
|
||||||
|
public partial class Utility
|
||||||
|
{
|
||||||
|
public class BotConfigCommands : NadekoSubmodule<IBotConfigProvider>
|
||||||
|
{
|
||||||
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
|
[OwnerOnly]
|
||||||
|
public async Task BotConfigEdit()
|
||||||
|
{
|
||||||
|
var names = Enum.GetNames(typeof(BotConfigEditType));
|
||||||
|
await ReplyAsync(string.Join(", ", names)).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
|
[OwnerOnly]
|
||||||
|
public async Task BotConfigEdit(BotConfigEditType type, [Remainder]string newValue = null)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(newValue))
|
||||||
|
newValue = null;
|
||||||
|
|
||||||
|
var success = _service.Edit(type, newValue);
|
||||||
|
|
||||||
|
if (!success)
|
||||||
|
await ReplyErrorLocalized("bot_config_edit_fail", Format.Bold(type.ToString()), Format.Bold(newValue ?? "NULL")).ConfigureAwait(false);
|
||||||
|
else
|
||||||
|
await ReplyConfirmLocalized("bot_config_edit_success", Format.Bold(type.ToString()), Format.Bold(newValue ?? "NULL")).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Utility.Common.Exceptions
|
namespace NadekoBot.Modules.Utility.Common.Exceptions
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Utility.Common.Exceptions
|
namespace NadekoBot.Modules.Utility.Common.Exceptions
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using System;
|
using System;
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using NadekoBot.Services.Database.Models;
|
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using Discord;
|
using Discord;
|
||||||
using NadekoBot.Common.Attributes;
|
using NadekoBot.Common.Attributes;
|
||||||
@ -16,11 +15,11 @@ namespace NadekoBot.Modules.Utility
|
|||||||
public class PatreonCommands : NadekoSubmodule<PatreonRewardsService>
|
public class PatreonCommands : NadekoSubmodule<PatreonRewardsService>
|
||||||
{
|
{
|
||||||
private readonly IBotCredentials _creds;
|
private readonly IBotCredentials _creds;
|
||||||
private readonly BotConfig _config;
|
private readonly IBotConfigProvider _config;
|
||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
private readonly CurrencyService _currency;
|
private readonly CurrencyService _currency;
|
||||||
|
|
||||||
public PatreonCommands(IBotCredentials creds, BotConfig config, DbService db, CurrencyService currency)
|
public PatreonCommands(IBotCredentials creds, IBotConfigProvider config, DbService db, CurrencyService currency)
|
||||||
{
|
{
|
||||||
_creds = creds;
|
_creds = creds;
|
||||||
_config = config;
|
_config = config;
|
||||||
@ -64,7 +63,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
|
|
||||||
if (amount > 0)
|
if (amount > 0)
|
||||||
{
|
{
|
||||||
await ReplyConfirmLocalized("clpa_success", amount + _config.CurrencySign).ConfigureAwait(false);
|
await ReplyConfirmLocalized("clpa_success", amount + _config.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var rem = (_service.Interval - (DateTime.UtcNow - _service.LastUpdate));
|
var rem = (_service.Interval - (DateTime.UtcNow - _service.LastUpdate));
|
||||||
|
@ -3,7 +3,6 @@ using Discord.Commands;
|
|||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -25,11 +25,11 @@ namespace NadekoBot.Modules.Utility.Services
|
|||||||
private readonly Logger _log;
|
private readonly Logger _log;
|
||||||
private readonly CancellationTokenSource cancelSource;
|
private readonly CancellationTokenSource cancelSource;
|
||||||
private readonly CancellationToken cancelAllToken;
|
private readonly CancellationToken cancelAllToken;
|
||||||
private readonly BotConfig _config;
|
private readonly IBotConfigProvider _config;
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
|
|
||||||
public RemindService(DiscordSocketClient client, BotConfig config, DbService db,
|
public RemindService(DiscordSocketClient client, IBotConfigProvider config, DbService db,
|
||||||
StartingGuildsService guilds, IUnitOfWork uow)
|
StartingGuildsService guilds, IUnitOfWork uow)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Utility.Services
|
|||||||
cancelAllToken = cancelSource.Token;
|
cancelAllToken = cancelSource.Token;
|
||||||
|
|
||||||
var reminders = uow.Reminders.GetIncludedReminders(guilds).ToList();
|
var reminders = uow.Reminders.GetIncludedReminders(guilds).ToList();
|
||||||
RemindMessageFormat = _config.RemindMessageFormat;
|
RemindMessageFormat = _config.BotConfig.RemindMessageFormat;
|
||||||
|
|
||||||
foreach (var r in reminders)
|
foreach (var r in reminders)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord;
|
using Discord;
|
||||||
|
@ -8,7 +8,6 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NadekoBot.Modules.Permissions;
|
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
@ -34,7 +33,6 @@ namespace NadekoBot
|
|||||||
public CommandService CommandService { get; }
|
public CommandService CommandService { get; }
|
||||||
|
|
||||||
public DbService Db { get; }
|
public DbService Db { get; }
|
||||||
public BotConfig BotConfig { get; }
|
|
||||||
public ImmutableArray<GuildConfig> AllGuildConfigs { get; private set; }
|
public ImmutableArray<GuildConfig> AllGuildConfigs { get; private set; }
|
||||||
|
|
||||||
/* I don't know how to make this not be static
|
/* I don't know how to make this not be static
|
||||||
@ -54,6 +52,8 @@ namespace NadekoBot
|
|||||||
|
|
||||||
private readonly ShardComClient _comClient;
|
private readonly ShardComClient _comClient;
|
||||||
|
|
||||||
|
private readonly BotConfig _botConfig;
|
||||||
|
|
||||||
public NadekoBot(int shardId, int parentProcessId, int? port = null)
|
public NadekoBot(int shardId, int parentProcessId, int? port = null)
|
||||||
{
|
{
|
||||||
if (shardId < 0)
|
if (shardId < 0)
|
||||||
@ -85,9 +85,9 @@ namespace NadekoBot
|
|||||||
|
|
||||||
using (var uow = Db.UnitOfWork)
|
using (var uow = Db.UnitOfWork)
|
||||||
{
|
{
|
||||||
BotConfig = uow.BotConfig.GetOrCreate();
|
_botConfig = uow.BotConfig.GetOrCreate();
|
||||||
OkColor = new Color(Convert.ToUInt32(BotConfig.OkColor, 16));
|
OkColor = new Color(Convert.ToUInt32(_botConfig.OkColor, 16));
|
||||||
ErrorColor = new Color(Convert.ToUInt32(BotConfig.ErrorColor, 16));
|
ErrorColor = new Color(Convert.ToUInt32(_botConfig.ErrorColor, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupShard(parentProcessId, port.Value);
|
SetupShard(parentProcessId, port.Value);
|
||||||
@ -124,13 +124,13 @@ namespace NadekoBot
|
|||||||
{
|
{
|
||||||
AllGuildConfigs = uow.GuildConfigs.GetAllGuildConfigs(startingGuildIdList).ToImmutableArray();
|
AllGuildConfigs = uow.GuildConfigs.GetAllGuildConfigs(startingGuildIdList).ToImmutableArray();
|
||||||
|
|
||||||
var localization = new Localization(BotConfig.Locale, AllGuildConfigs.ToDictionary(x => x.GuildId, x => x.Locale), Db);
|
var localization = new Localization(_botConfig.Locale, AllGuildConfigs.ToDictionary(x => x.GuildId, x => x.Locale), Db);
|
||||||
|
|
||||||
//initialize Services
|
//initialize Services
|
||||||
Services = new NServiceProvider.ServiceProviderBuilder()
|
Services = new NServiceProvider.ServiceProviderBuilder()
|
||||||
.AddManual<IBotCredentials>(Credentials)
|
.AddManual<IBotCredentials>(Credentials)
|
||||||
.AddManual(Db)
|
.AddManual(Db)
|
||||||
.AddManual(BotConfig)
|
.AddManual(_botConfig)
|
||||||
.AddManual(Client)
|
.AddManual(Client)
|
||||||
.AddManual(CommandService)
|
.AddManual(CommandService)
|
||||||
.AddManual<ILocalization>(localization)
|
.AddManual<ILocalization>(localization)
|
||||||
|
@ -91,8 +91,4 @@
|
|||||||
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
|
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
|
||||||
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
|
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Utility\Modules\" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -3573,4 +3573,13 @@
|
|||||||
<data name="streamrolewhitelist_desc" xml:space="preserve">
|
<data name="streamrolewhitelist_desc" xml:space="preserve">
|
||||||
<value>Adds or removes a whitelisted user. Whitelisted users will receive the stream role even if they don't have the specified keyword in their stream title.</value>
|
<value>Adds or removes a whitelisted user. Whitelisted users will receive the stream role even if they don't have the specified keyword in their stream title.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="botconfigedit_cmd" xml:space="preserve">
|
||||||
|
<value>botconfigedit bce</value>
|
||||||
|
</data>
|
||||||
|
<data name="botconfigedit_usage" xml:space="preserve">
|
||||||
|
<value>`{0}bce CurrencyName b1nzy` or `{0}bce`</value>
|
||||||
|
</data>
|
||||||
|
<data name="botconfigedit_desc" xml:space="preserve">
|
||||||
|
<value>Sets one of available bot config settings to a specified value. Use the command without any parameters to get a list of available settings.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
@ -50,7 +50,7 @@ namespace NadekoBot.Services
|
|||||||
public ConcurrentHashSet<ulong> UsersOnShortCooldown { get; } = new ConcurrentHashSet<ulong>();
|
public ConcurrentHashSet<ulong> UsersOnShortCooldown { get; } = new ConcurrentHashSet<ulong>();
|
||||||
private readonly Timer _clearUsersOnShortCooldown;
|
private readonly Timer _clearUsersOnShortCooldown;
|
||||||
|
|
||||||
public CommandHandler(DiscordSocketClient client, DbService db, BotConfig bc, IEnumerable<GuildConfig> gcs, CommandService commandService, IBotCredentials credentials, NadekoBot bot)
|
public CommandHandler(DiscordSocketClient client, DbService db, IBotConfigProvider bc, IEnumerable<GuildConfig> gcs, CommandService commandService, IBotCredentials credentials, NadekoBot bot)
|
||||||
{
|
{
|
||||||
_client = client;
|
_client = client;
|
||||||
_commandService = commandService;
|
_commandService = commandService;
|
||||||
@ -65,7 +65,7 @@ namespace NadekoBot.Services
|
|||||||
UsersOnShortCooldown.Clear();
|
UsersOnShortCooldown.Clear();
|
||||||
}, null, GlobalCommandsCooldown, GlobalCommandsCooldown);
|
}, null, GlobalCommandsCooldown, GlobalCommandsCooldown);
|
||||||
|
|
||||||
DefaultPrefix = bc.DefaultPrefix;
|
DefaultPrefix = bc.BotConfig.DefaultPrefix;
|
||||||
_prefixes = gcs
|
_prefixes = gcs
|
||||||
.Where(x => x.Prefix != null)
|
.Where(x => x.Prefix != null)
|
||||||
.ToDictionary(x => x.GuildId, x => x.Prefix)
|
.ToDictionary(x => x.GuildId, x => x.Prefix)
|
||||||
|
@ -9,10 +9,10 @@ namespace NadekoBot.Services
|
|||||||
{
|
{
|
||||||
public class CurrencyService : INService
|
public class CurrencyService : INService
|
||||||
{
|
{
|
||||||
private readonly BotConfig _config;
|
private readonly IBotConfigProvider _config;
|
||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
|
|
||||||
public CurrencyService(BotConfig config, DbService db)
|
public CurrencyService(IBotConfigProvider config, DbService db)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_db = db;
|
_db = db;
|
||||||
@ -23,7 +23,7 @@ namespace NadekoBot.Services
|
|||||||
var success = await RemoveAsync(author.Id, reason, amount);
|
var success = await RemoveAsync(author.Id, reason, amount);
|
||||||
|
|
||||||
if (success && sendMessage)
|
if (success && sendMessage)
|
||||||
try { await author.SendErrorAsync($"`You lost:` {amount} {_config.CurrencySign}\n`Reason:` {reason}").ConfigureAwait(false); } catch { }
|
try { await author.SendErrorAsync($"`You lost:` {amount} {_config.BotConfig.CurrencySign}\n`Reason:` {reason}").ConfigureAwait(false); } catch { }
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ namespace NadekoBot.Services
|
|||||||
await AddAsync(author.Id, reason, amount);
|
await AddAsync(author.Id, reason, amount);
|
||||||
|
|
||||||
if (sendMessage)
|
if (sendMessage)
|
||||||
try { await author.SendConfirmAsync($"`You received:` {amount} {_config.CurrencySign}\n`Reason:` {reason}").ConfigureAwait(false); } catch { }
|
try { await author.SendConfirmAsync($"`You received:` {amount} {_config.BotConfig.CurrencySign}\n`Reason:` {reason}").ConfigureAwait(false); } catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddAsync(ulong receiverId, string reason, long amount, IUnitOfWork uow = null)
|
public async Task AddAsync(ulong receiverId, string reason, long amount, IUnitOfWork uow = null)
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace NadekoBot.Services.Database.Models
|
namespace NadekoBot.Services.Database.Models
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace NadekoBot.Services.Database.Repositories
|
namespace NadekoBot.Services.Database.Repositories
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace NadekoBot.Services.Database.Repositories.Impl
|
namespace NadekoBot.Services.Database.Repositories.Impl
|
||||||
{
|
{
|
||||||
|
12
src/NadekoBot/Services/IBotConfigProvider.cs
Normal file
12
src/NadekoBot/Services/IBotConfigProvider.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using NadekoBot.Common;
|
||||||
|
using NadekoBot.Services.Database.Models;
|
||||||
|
|
||||||
|
namespace NadekoBot.Services
|
||||||
|
{
|
||||||
|
public interface IBotConfigProvider : INService
|
||||||
|
{
|
||||||
|
BotConfig BotConfig { get; }
|
||||||
|
void Reload();
|
||||||
|
bool Edit(BotConfigEditType type, string newValue);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Immutable;
|
||||||
using System.Collections.Immutable;
|
|
||||||
|
|
||||||
namespace NadekoBot.Services
|
namespace NadekoBot.Services
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace NadekoBot.Services
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace NadekoBot.Services
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All services must implement this interface in order to be auto-discovered by the DI system
|
/// All services must implement this interface in order to be auto-discovered by the DI system
|
||||||
|
111
src/NadekoBot/Services/Impl/BotConfigProvider.cs
Normal file
111
src/NadekoBot/Services/Impl/BotConfigProvider.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using System;
|
||||||
|
using NadekoBot.Common;
|
||||||
|
using NadekoBot.Services.Database.Models;
|
||||||
|
using NadekoBot.Services;
|
||||||
|
|
||||||
|
namespace NadekoBot.Services.Impl
|
||||||
|
{
|
||||||
|
public class BotConfigProvider : IBotConfigProvider
|
||||||
|
{
|
||||||
|
private readonly DbService _db;
|
||||||
|
public BotConfig BotConfig { get; private set; }
|
||||||
|
|
||||||
|
public BotConfigProvider(DbService db, BotConfig bc)
|
||||||
|
{
|
||||||
|
_db = db;
|
||||||
|
BotConfig = bc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reload()
|
||||||
|
{
|
||||||
|
using (var uow = _db.UnitOfWork)
|
||||||
|
{
|
||||||
|
BotConfig = uow.BotConfig.GetOrCreate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Edit(BotConfigEditType type, string newValue)
|
||||||
|
{
|
||||||
|
using (var uow = _db.UnitOfWork)
|
||||||
|
{
|
||||||
|
var bc = uow.BotConfig.GetOrCreate();
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case BotConfigEditType.CurrencyGenerationChance:
|
||||||
|
if (float.TryParse(newValue, out var chance)
|
||||||
|
&& chance >= 0
|
||||||
|
&& chance <= 1)
|
||||||
|
{
|
||||||
|
bc.CurrencyGenerationChance = chance;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BotConfigEditType.CurrencyGenerationCooldown:
|
||||||
|
if (int.TryParse(newValue, out var cd) && cd >= 1)
|
||||||
|
{
|
||||||
|
bc.CurrencyGenerationCooldown = cd;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BotConfigEditType.CurrencyName:
|
||||||
|
bc.CurrencyName = newValue ?? "-";
|
||||||
|
break;
|
||||||
|
case BotConfigEditType.CurrencyPluralName:
|
||||||
|
bc.CurrencyPluralName = newValue ?? bc.CurrencyName + "s";
|
||||||
|
break;
|
||||||
|
case BotConfigEditType.CurrencySign:
|
||||||
|
bc.CurrencySign = newValue ?? "-";
|
||||||
|
break;
|
||||||
|
case BotConfigEditType.DmHelpString:
|
||||||
|
bc.DMHelpString = string.IsNullOrWhiteSpace(newValue)
|
||||||
|
? "-"
|
||||||
|
: newValue;
|
||||||
|
break;
|
||||||
|
case BotConfigEditType.HelpString:
|
||||||
|
bc.HelpString = string.IsNullOrWhiteSpace(newValue)
|
||||||
|
? "-"
|
||||||
|
: newValue;
|
||||||
|
break;
|
||||||
|
case BotConfigEditType.CurrencyDropAmount:
|
||||||
|
if (int.TryParse(newValue, out var amount) && amount > 0)
|
||||||
|
bc.CurrencyDropAmount = amount;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case BotConfigEditType.CurrencyDropAmountMax:
|
||||||
|
if (newValue == null)
|
||||||
|
bc.CurrencyDropAmountMax = null;
|
||||||
|
else if (int.TryParse(newValue, out var maxAmount) && maxAmount > 0)
|
||||||
|
bc.CurrencyDropAmountMax = maxAmount;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case BotConfigEditType.MinimumBetAmount:
|
||||||
|
if (int.TryParse(newValue, out var minBetAmount) && minBetAmount > 0)
|
||||||
|
bc.MinimumBetAmount = minBetAmount;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case BotConfigEditType.TriviaCurrencyReward:
|
||||||
|
if (int.TryParse(newValue, out var triviaReward) && triviaReward > 0)
|
||||||
|
bc.TriviaCurrencyReward = triviaReward;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BotConfig = bc;
|
||||||
|
uow.Complete();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
using NLog;
|
using NLog;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace NadekoBot.Services.Impl
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace NadekoBot.Services.Impl
|
|
||||||
{
|
{
|
||||||
public class SyncPreconditionService
|
public class SyncPreconditionService
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
using NLog;
|
using NLog;
|
||||||
using NLog.Config;
|
using NLog.Config;
|
||||||
using NLog.Targets;
|
using NLog.Targets;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace NadekoBot.Services
|
namespace NadekoBot.Services
|
||||||
{
|
{
|
||||||
|
@ -48,6 +48,8 @@ namespace NadekoBot.Services
|
|||||||
var interfaces = new HashSet<Type>(allTypes
|
var interfaces = new HashSet<Type>(allTypes
|
||||||
.Where(x => x.GetInterfaces().Contains(typeof(INService)) && x.GetTypeInfo().IsInterface));
|
.Where(x => x.GetInterfaces().Contains(typeof(INService)) && x.GetTypeInfo().IsInterface));
|
||||||
|
|
||||||
|
var alreadyFailed = new Dictionary<Type, int>();
|
||||||
|
|
||||||
var sw = Stopwatch.StartNew();
|
var sw = Stopwatch.StartNew();
|
||||||
var swInstance = new Stopwatch();
|
var swInstance = new Stopwatch();
|
||||||
while (services.Count > 0)
|
while (services.Count > 0)
|
||||||
@ -71,11 +73,20 @@ namespace NadekoBot.Services
|
|||||||
else //if i failed getting it, add it to the end, and break
|
else //if i failed getting it, add it to the end, and break
|
||||||
{
|
{
|
||||||
services.Enqueue(type);
|
services.Enqueue(type);
|
||||||
|
if (alreadyFailed.ContainsKey(type))
|
||||||
|
{
|
||||||
|
alreadyFailed[type]++;
|
||||||
|
if (alreadyFailed[type] > 3)
|
||||||
|
_log.Warn(type.Name + " wasn't instantiated in the first 3 attempts. Missing " + arg.Name + " type");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
alreadyFailed.Add(type, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.Count != argTypes.Length)
|
if (args.Count != argTypes.Length)
|
||||||
continue;
|
continue;
|
||||||
|
// _log.Info("Loading " + type.Name);
|
||||||
swInstance.Restart();
|
swInstance.Restart();
|
||||||
var instance = ctor.Invoke(args.ToArray());
|
var instance = ctor.Invoke(args.ToArray());
|
||||||
swInstance.Stop();
|
swInstance.Stop();
|
||||||
|
@ -16,7 +16,6 @@ using System.Text.RegularExpressions;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NadekoBot.Common.Collections;
|
using NadekoBot.Common.Collections;
|
||||||
using SixLabors.Primitives;
|
using SixLabors.Primitives;
|
||||||
using ImageSharp.PixelFormats;
|
|
||||||
|
|
||||||
namespace NadekoBot.Extensions
|
namespace NadekoBot.Extensions
|
||||||
{
|
{
|
||||||
|
@ -626,6 +626,8 @@
|
|||||||
"utility_activity_users_total": "{0} users total.",
|
"utility_activity_users_total": "{0} users total.",
|
||||||
"utility_author": "Author",
|
"utility_author": "Author",
|
||||||
"utility_botid": "Bot ID",
|
"utility_botid": "Bot ID",
|
||||||
|
"utility_bot_config_edit_fail": "Failed setting {0} to the value {1}",
|
||||||
|
"utility_bot_config_edit_success": "The value of {0} is set to {1}",
|
||||||
"utility_calcops": "List of functions in {0}calc command",
|
"utility_calcops": "List of functions in {0}calc command",
|
||||||
"utility_channelid": "{0} of this channel is {1}",
|
"utility_channelid": "{0} of this channel is {1}",
|
||||||
"utility_channel_topic": "Channel topic",
|
"utility_channel_topic": "Channel topic",
|
||||||
|
Loading…
Reference in New Issue
Block a user