Cleanup part1
This commit is contained in:
parent
cdd63786ff
commit
4a2fc087f3
@ -27,12 +27,8 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
_log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var conf = uow.BotConfig.GetOrCreate();
|
||||
RotatingStatusMessages = conf.RotatingStatusMessages;
|
||||
RotatingStatuses = conf.RotatingStatuses;
|
||||
}
|
||||
RotatingStatusMessages = NadekoBot.BotConfig.RotatingStatusMessages;
|
||||
RotatingStatuses = NadekoBot.BotConfig.RotatingStatuses;
|
||||
|
||||
var t = Task.Run(async () =>
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
animals = new ConcurrentQueue<string>(uow.BotConfig.GetOrCreate().RaceAnimals.Select(ra => ra.Icon).Shuffle());
|
||||
animals = new ConcurrentQueue<string>(NadekoBot.BotConfig.RaceAnimals.Select(ra => ra.Icon).Shuffle());
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,14 +20,9 @@ namespace NadekoBot.Modules.Gambling
|
||||
|
||||
static Gambling()
|
||||
{
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var conf = uow.BotConfig.GetOrCreate();
|
||||
|
||||
CurrencyName = conf.CurrencyName;
|
||||
CurrencySign = conf.CurrencySign;
|
||||
CurrencyPluralName = conf.CurrencyPluralName;
|
||||
}
|
||||
CurrencyName = NadekoBot.BotConfig.CurrencyName;
|
||||
CurrencyPluralName = NadekoBot.BotConfig.CurrencyPluralName;
|
||||
CurrencySign = NadekoBot.BotConfig.CurrencySign;
|
||||
}
|
||||
|
||||
public static long GetCurrency(ulong id)
|
||||
|
@ -38,32 +38,17 @@ namespace NadekoBot.Modules.Games
|
||||
|
||||
private static ConcurrentHashSet<ulong> usersRecentlyPicked { get; } = new ConcurrentHashSet<ulong>();
|
||||
|
||||
private static float chance { get; }
|
||||
private static int cooldown { get; }
|
||||
private static Logger _log { get; }
|
||||
|
||||
static PlantPickCommands()
|
||||
{
|
||||
_log = LogManager.GetCurrentClassLogger();
|
||||
var sw = Stopwatch.StartNew();
|
||||
|
||||
|
||||
#if !GLOBAL_NADEKO
|
||||
NadekoBot.Client.MessageReceived += PotentialFlowerGeneration;
|
||||
#endif
|
||||
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var conf = uow.BotConfig.GetOrCreate();
|
||||
var x =
|
||||
generationChannels = new ConcurrentHashSet<ulong>(NadekoBot.AllGuildConfigs
|
||||
.SelectMany(c => c.GenerateCurrencyChannelIds.Select(obj => obj.ChannelId)));
|
||||
chance = conf.CurrencyGenerationChance;
|
||||
cooldown = conf.CurrencyGenerationCooldown;
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
_log.Debug($"Loaded in {sw.Elapsed.TotalSeconds:F2}s");
|
||||
generationChannels = new ConcurrentHashSet<ulong>(NadekoBot.AllGuildConfigs
|
||||
.SelectMany(c => c.GenerateCurrencyChannelIds.Select(obj => obj.ChannelId)));
|
||||
}
|
||||
|
||||
private static async void PotentialFlowerGeneration(SocketMessage imsg)
|
||||
@ -84,10 +69,10 @@ namespace NadekoBot.Modules.Games
|
||||
var lastGeneration = lastGenerations.GetOrAdd(channel.Id, DateTime.MinValue);
|
||||
var rng = new NadekoRandom();
|
||||
|
||||
if (DateTime.Now - TimeSpan.FromSeconds(cooldown) < lastGeneration) //recently generated in this channel, don't generate again
|
||||
if (DateTime.Now - TimeSpan.FromSeconds(NadekoBot.BotConfig.CurrencyGenerationCooldown) < lastGeneration) //recently generated in this channel, don't generate again
|
||||
return;
|
||||
|
||||
var num = rng.Next(1, 101) + chance * 100;
|
||||
var num = rng.Next(1, 101) + NadekoBot.BotConfig.CurrencyGenerationChance * 100;
|
||||
|
||||
if (num > 100)
|
||||
{
|
||||
|
@ -13,14 +13,7 @@ namespace NadekoBot.Modules.Games
|
||||
[NadekoModule("Games", ">")]
|
||||
public partial class Games : DiscordModule
|
||||
{
|
||||
private IEnumerable<string> _8BallResponses {
|
||||
get {
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
return uow.BotConfig.GetOrCreate().EightBallResponses.Select(ebr => ebr.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static IEnumerable<string> _8BallResponses { get; } = NadekoBot.BotConfig.EightBallResponses.Select(ebr => ebr.Text);
|
||||
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
|
@ -15,26 +15,10 @@ namespace NadekoBot.Modules.Help
|
||||
[NadekoModule("Help", "-")]
|
||||
public partial class Help : DiscordModule
|
||||
{
|
||||
private static string helpString { get; }
|
||||
private static string helpString { get; } = NadekoBot.BotConfig.HelpString;
|
||||
public static string HelpString => String.Format(helpString, NadekoBot.Credentials.ClientId, NadekoBot.ModulePrefixes[typeof(Help).Name]);
|
||||
|
||||
public static string DMHelpString { get; }
|
||||
|
||||
static Help()
|
||||
{
|
||||
|
||||
//todo don't cache this, just query db when someone wants -h
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var config = uow.BotConfig.GetOrCreate();
|
||||
helpString = config.HelpString;
|
||||
DMHelpString = config.DMHelpString;
|
||||
}
|
||||
}
|
||||
|
||||
public Help() : base()
|
||||
{
|
||||
}
|
||||
public static string DMHelpString { get; } = NadekoBot.BotConfig.DMHelpString;
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
public async Task Modules()
|
||||
|
@ -40,9 +40,8 @@ namespace NadekoBot.Modules.Utility
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
reminders = uow.Reminders.GetAll().ToList();
|
||||
|
||||
RemindMessageFormat = uow.BotConfig.GetOrCreate().RemindMessageFormat;
|
||||
}
|
||||
RemindMessageFormat = NadekoBot.BotConfig.RemindMessageFormat;
|
||||
|
||||
foreach (var r in reminders)
|
||||
{
|
||||
|
@ -38,6 +38,7 @@ namespace NadekoBot
|
||||
public static bool Ready { get; private set; }
|
||||
|
||||
public static IEnumerable<GuildConfig> AllGuildConfigs { get; }
|
||||
public static BotConfig BotConfig { get; }
|
||||
|
||||
static NadekoBot()
|
||||
{
|
||||
@ -47,6 +48,7 @@ namespace NadekoBot
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
AllGuildConfigs = uow.GuildConfigs.GetAllGuildConfigs();
|
||||
BotConfig = uow.BotConfig.GetOrCreate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,10 +100,9 @@ namespace NadekoBot
|
||||
_log.Info("Connected");
|
||||
|
||||
//load commands and prefixes
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
ModulePrefixes = new ConcurrentDictionary<string, string>(uow.BotConfig.GetOrCreate().ModulePrefixes.OrderByDescending(mp => mp.Prefix.Length).ToDictionary(m => m.ModuleName, m => m.Prefix));
|
||||
}
|
||||
|
||||
ModulePrefixes = new ConcurrentDictionary<string, string>(NadekoBot.BotConfig.ModulePrefixes.OrderByDescending(mp => mp.Prefix.Length).ToDictionary(m => m.ModuleName, m => m.Prefix));
|
||||
|
||||
// start handling messages received in commandhandler
|
||||
await CommandHandler.StartHandling().ConfigureAwait(false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user