public Help(IBotCredentials creds, GlobalPermissionService perms, IBotConfigProvider config, CommandService cmds) { _creds = creds; _config = config; _cmds = cmds; _perms = perms; }
public Help(IBotCredentials creds, GlobalPermissionService perms, CommandService cmds, IServiceProvider services) { _creds = creds; _cmds = cmds; _perms = perms; _services = services; }
public Help(IBotCredentials creds, GlobalPermissionService perms, CommandService cmds, IServiceProvider services, DiscordSocketClient client) { _creds = creds; _cmds = cmds; _perms = perms; _services = services; _client = client; _lazyClientId = new AsyncLazy <ulong>(async() => (await _client.GetApplicationInfoAsync()).Id); }
public CustomReactionsService(PermissionService perms, DbService db, NadekoStrings strings, DiscordSocketClient client, CommandHandler cmd, IBotConfigProvider bc, IUnitOfWork uow, IDataCache cache, GlobalPermissionService gperm, NadekoBot bot) { _log = LogManager.GetCurrentClassLogger(); _db = db; _client = client; _perms = perms; _cmd = cmd; _bc = bc; _strings = strings; _cache = cache; _gperm = gperm; var sub = _cache.Redis.GetSubscriber(); sub.Subscribe(_client.CurrentUser.Id + "_gcr.added", (ch, msg) => { var cr = JsonConvert.DeserializeObject <CustomReaction>(msg); _globalReactions.TryAdd(cr.Id, cr); }, StackExchange.Redis.CommandFlags.FireAndForget); sub.Subscribe(_client.CurrentUser.Id + "_gcr.deleted", (ch, msg) => { var id = int.Parse(msg); _globalReactions.TryRemove(id, out _); }, StackExchange.Redis.CommandFlags.FireAndForget); sub.Subscribe(_client.CurrentUser.Id + "_gcr.edited", (ch, msg) => { var obj = new { Id = 0, Res = "", Ad = false, Dm = false, Ca = false }; obj = JsonConvert.DeserializeAnonymousType(msg, obj); if (_globalReactions.TryGetValue(obj.Id, out var gcr)) { gcr.Response = obj.Res; gcr.AutoDeleteTrigger = obj.Ad; gcr.DmResponse = obj.Dm; gcr.ContainsAnywhere = obj.Ca; } }, StackExchange.Redis.CommandFlags.FireAndForget); var guildItems = uow.CustomReactions.GetFor(bot.AllGuildConfigs.Select(x => x.GuildId)); _guildReactions = new ConcurrentDictionary <ulong, ConcurrentDictionary <int, CustomReaction> >(guildItems .GroupBy(k => k.GuildId.Value) .ToDictionary(g => g.Key, g => g.ToDictionary(x => x.Id, x => x).ToConcurrent())); var globalItems = uow.CustomReactions.GetGlobal(); _globalReactions = globalItems .ToDictionary(x => x.Id, x => x) .ToConcurrent(); bot.JoinedGuild += Bot_JoinedGuild; _client.LeftGuild += _client_LeftGuild; }
public Help(GlobalPermissionService perms, CommandService cmds, BotConfigService bss, IServiceProvider services, DiscordSocketClient client, IBotStrings strings) { _cmds = cmds; _bss = bss; _perms = perms; _services = services; _client = client; _strings = strings; _lazyClientId = new AsyncLazy <ulong>(async() => (await _client.GetApplicationInfoAsync()).Id); }
public CustomReactionsService(PermissionService perms, DbService db, NadekoStrings strings, DiscordSocketClient client, CommandHandler cmd, IBotConfigProvider bc, IUnitOfWork uow, IDataCache cache, GlobalPermissionService gperm, NadekoBot bot) { _log = LogManager.GetCurrentClassLogger(); _db = db; _client = client; _perms = perms; _cmd = cmd; _bc = bc; _strings = strings; _cache = cache; _gperm = gperm; var sub = _cache.Redis.GetSubscriber(); sub.Subscribe(_client.CurrentUser.Id + "_gcr.added", (ch, msg) => { Array.Resize(ref GlobalReactions, GlobalReactions.Length + 1); GlobalReactions[GlobalReactions.Length - 1] = JsonConvert.DeserializeObject <CustomReaction>(msg); }, StackExchange.Redis.CommandFlags.FireAndForget); sub.Subscribe(_client.CurrentUser.Id + "_gcr.deleted", (ch, msg) => { var id = int.Parse(msg); GlobalReactions = GlobalReactions.Where(cr => cr?.Id != id).ToArray(); }, StackExchange.Redis.CommandFlags.FireAndForget); sub.Subscribe(_client.CurrentUser.Id + "_gcr.edited", (ch, msg) => { var obj = new { Id = 0, Res = "", Ad = false, Dm = false, Ca = false }; obj = JsonConvert.DeserializeAnonymousType(msg, obj); var gcr = GlobalReactions.FirstOrDefault(x => x.Id == obj.Id); if (gcr != null) { gcr.Response = obj.Res; gcr.AutoDeleteTrigger = obj.Ad; gcr.DmResponse = obj.Dm; gcr.ContainsAnywhere = obj.Ca; } }, StackExchange.Redis.CommandFlags.FireAndForget); var items = uow.CustomReactions.GetGlobalAndFor(bot.AllGuildConfigs.Select(x => (long)x.GuildId)); GuildReactions = new ConcurrentDictionary <ulong, CustomReaction[]>(items .Where(g => g.GuildId != null && g.GuildId != 0) .GroupBy(k => k.GuildId.Value) .ToDictionary(g => g.Key, g => g.ToArray())); GlobalReactions = items.Where(g => g.GuildId == null || g.GuildId == 0).ToArray(); bot.JoinedGuild += Bot_JoinedGuild; _client.LeftGuild += _client_LeftGuild; }
public CustomReactionsService(PermissionService perms, DbService db, NadekoStrings strings, DiscordSocketClient client, CommandHandler cmd, IBotConfigProvider bc, IDataCache cache, GlobalPermissionService gperm, NadekoBot bot) { _log = LogManager.GetCurrentClassLogger(); _db = db; _client = client; _perms = perms; _cmd = cmd; _bc = bc; _strings = strings; _cache = cache; _gperm = gperm; var sub = _cache.Redis.GetSubscriber(); sub.Subscribe(_client.CurrentUser.Id + "_crs.reload", (ch, msg) => { ReloadInternal(bot.GetCurrentGuildConfigs()); }, StackExchange.Redis.CommandFlags.FireAndForget); sub.Subscribe(_client.CurrentUser.Id + "_gcr.added", (ch, msg) => { var cr = JsonConvert.DeserializeObject <CustomReaction>(msg); _globalReactions.TryAdd(cr.Id, cr); }, StackExchange.Redis.CommandFlags.FireAndForget); sub.Subscribe(_client.CurrentUser.Id + "_gcr.deleted", (ch, msg) => { var id = int.Parse(msg); _globalReactions.TryRemove(id, out _); }, StackExchange.Redis.CommandFlags.FireAndForget); sub.Subscribe(_client.CurrentUser.Id + "_gcr.edited", (ch, msg) => { var obj = new { Id = 0, Res = "", Ad = false, Dm = false, Ca = false, Re = "" }; obj = JsonConvert.DeserializeAnonymousType(msg, obj); if (_globalReactions.TryGetValue(obj.Id, out var gcr)) { gcr.Response = obj.Res; gcr.AutoDeleteTrigger = obj.Ad; gcr.DmResponse = obj.Dm; gcr.ContainsAnywhere = obj.Ca; gcr.Reactions = obj.Re; } }, StackExchange.Redis.CommandFlags.FireAndForget); ReloadInternal(bot.AllGuildConfigs); bot.JoinedGuild += Bot_JoinedGuild; _client.LeftGuild += _client_LeftGuild; }
public CustomReactionsService(PermissionService perms, DbService db, IBotStrings strings, NadekoBot bot, DiscordSocketClient client, CommandHandler cmd, GlobalPermissionService gperm, CmdCdService cmdCds, IPubSub pubSub) { _db = db; _client = client; _perms = perms; _cmd = cmd; _strings = strings; _bot = bot; _gperm = gperm; _cmdCds = cmdCds; _pubSub = pubSub; _rng = new NadekoRandom(); _pubSub.Sub(_crsReloadedKey, OnCrsShouldReload); pubSub.Sub(_gcrAddedKey, OnGcrAdded); pubSub.Sub(_gcrDeletedkey, OnGcrDeleted); pubSub.Sub(_gcrEditedKey, OnGcrEdited); bot.JoinedGuild += OnJoinedGuild; _client.LeftGuild += OnLeftGuild; }
public ResetPermissionsCommands(GlobalPermissionService gps, PermissionService perms) { _gps = gps; _perms = perms; }
public GlobalPermissionCommands(GlobalPermissionService service, DbService db) { _service = service; _db = db; }
public Help(GlobalPermissionService perms, CommandService cmds) { _cmds = cmds; _perms = perms; }
public Help(IBotCredentials creds, GlobalPermissionService perms, CommandService cmds) { _creds = creds; _cmds = cmds; _perms = perms; }
public GlobalPermissionCommands(GlobalPermissionService service, IUnitOfWork uow) { _service = service; this.uow = uow; }