public XpConfigMigrator(DbService dbService, XpConfigService gss) { _db = dbService; _gss = gss; }
public XpService(DiscordSocketClient client, CommandHandler cmd, NadekoBot bot, DbService db, IBotStrings strings, IDataCache cache, FontProvider fonts, IBotCredentials creds, ICurrencyService cs, IHttpClientFactory http, XpConfigService xpConfig) { _db = db; _cmd = cmd; _images = cache.LocalImages; _strings = strings; _cache = cache; _fonts = fonts; _creds = creds; _cs = cs; _httpFactory = http; _xpConfig = xpConfig; _excludedServers = new ConcurrentHashSet <ulong>(); _excludedChannels = new ConcurrentDictionary <ulong, ConcurrentHashSet <ulong> >(); _client = client; InternalReloadXpTemplate(); if (client.ShardId == 0) { var sub = _cache.Redis.GetSubscriber(); sub.Subscribe(_creds.RedisKey() + "_reload_xp_template", (ch, val) => InternalReloadXpTemplate()); } //load settings var allGuildConfigs = bot.AllGuildConfigs .Where(x => x.XpSettings != null) .ToList(); _excludedChannels = allGuildConfigs .ToDictionary( x => x.GuildId, x => new ConcurrentHashSet <ulong>(x.XpSettings .ExclusionList .Where(ex => ex.ItemType == ExcludedItemType.Channel) .Select(ex => ex.ItemId) .Distinct())) .ToConcurrent(); _excludedRoles = allGuildConfigs .ToDictionary( x => x.GuildId, x => new ConcurrentHashSet <ulong>(x.XpSettings .ExclusionList .Where(ex => ex.ItemType == ExcludedItemType.Role) .Select(ex => ex.ItemId) .Distinct())) .ToConcurrent(); _excludedServers = new ConcurrentHashSet <ulong>( allGuildConfigs.Where(x => x.XpSettings.ServerExcluded) .Select(x => x.GuildId)); _cmd.OnMessageNoTrigger += _cmd_OnMessageNoTrigger; #if !GLOBAL_NADEKO _client.UserVoiceStateUpdated += _client_OnUserVoiceStateUpdated; // Scan guilds on startup. _client.GuildAvailable += _client_OnGuildAvailable; foreach (var guild in _client.Guilds) { _client_OnGuildAvailable(guild); } #endif updateXpTask = Task.Run(UpdateLoop); }