Fixed converter?

This commit is contained in:
Master Kwoth 2017-07-05 16:41:51 +02:00
parent 3a71f63754
commit ab07199a1e
2 changed files with 30 additions and 22 deletions

View File

@ -162,7 +162,7 @@ namespace NadekoBot
#region utility
var remindService = new RemindService(Client, BotConfig, Db, startingGuildIdList, uow);
var repeaterService = new MessageRepeaterService(this, Client, AllGuildConfigs);
//var converterService = new ConverterService(Db);
var converterService = new ConverterService(Client, Db);
var commandMapService = new CommandMapService(AllGuildConfigs);
var patreonRewardsService = new PatreonRewardsService(Credentials, Db, Currency, Client);
var verboseErrorsService = new VerboseErrorsService(AllGuildConfigs, Db, CommandHandler, helpService);
@ -232,7 +232,7 @@ namespace NadekoBot
.Add(commandMapService)
.Add(remindService)
.Add(repeaterService)
//.Add(converterService)
.Add(converterService)
.Add(verboseErrorsService)
.Add(patreonRewardsService)
.Add(pruneService)

View File

@ -25,6 +25,9 @@ namespace NadekoBot.Services.Utility
{
_log = LogManager.GetCurrentClassLogger();
_db = db;
if (client.ShardId == 0)
{
try
{
var data = JsonConvert.DeserializeObject<List<MeasurementUnit>>(
@ -41,17 +44,22 @@ namespace NadekoBot.Services.Utility
if (uow.ConverterUnits.Empty())
{
uow.ConverterUnits.AddRange(data);
Units = uow.ConverterUnits.GetAll().ToList();
uow.Complete();
}
}
Units = data.ToList();
}
catch (Exception ex)
{
_log.Warn("Could not load units: " + ex.Message);
}
}
_currencyUpdater = new Timer(async (shouldLoad) => await UpdateCurrency((bool)shouldLoad), client.ShardId == 0, _updateInterval, _updateInterval);
_currencyUpdater = new Timer(async (shouldLoad) => await UpdateCurrency((bool)shouldLoad),
client.ShardId == 0,
TimeSpan.FromSeconds(1),
_updateInterval);
}
private async Task<Rates> GetCurrencyRates()