triggered permissions are now translatable
This commit is contained in:
		@@ -165,7 +165,7 @@ namespace NadekoBot
 | 
			
		||||
                #endregion
 | 
			
		||||
 | 
			
		||||
                #region permissions
 | 
			
		||||
                var permissionsService = new PermissionService(Client, Db, BotConfig, CommandHandler);
 | 
			
		||||
                var permissionsService = new PermissionService(Client, Db, BotConfig, CommandHandler, Strings);
 | 
			
		||||
                var blacklistService = new BlacklistService(BotConfig);
 | 
			
		||||
                var cmdcdsService = new CmdCdService(AllGuildConfigs);
 | 
			
		||||
                var filterService = new FilterService(Client, AllGuildConfigs);
 | 
			
		||||
@@ -180,11 +180,11 @@ namespace NadekoBot
 | 
			
		||||
 | 
			
		||||
                var clashService = new ClashOfClansService(Client, Db, Localization, Strings, uow, startingGuildIdList);
 | 
			
		||||
                var musicService = new MusicService(GoogleApi, Strings, Localization, Db, soundcloudApiService, Credentials, AllGuildConfigs);
 | 
			
		||||
                var crService = new CustomReactionsService(permissionsService, Db, Client, CommandHandler, BotConfig, uow);
 | 
			
		||||
                var crService = new CustomReactionsService(permissionsService, Db, Strings, Client, CommandHandler, BotConfig, uow);
 | 
			
		||||
 | 
			
		||||
                #region Games
 | 
			
		||||
                var gamesService = new GamesService(Client, BotConfig, AllGuildConfigs, Strings, Images, CommandHandler);
 | 
			
		||||
                var chatterBotService = new ChatterBotService(Client, permissionsService, AllGuildConfigs, CommandHandler);
 | 
			
		||||
                var chatterBotService = new ChatterBotService(Client, permissionsService, AllGuildConfigs, CommandHandler, Strings);
 | 
			
		||||
                var pollService = new PollService(Client, Strings);
 | 
			
		||||
                #endregion
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,8 +27,9 @@ namespace NadekoBot.Services.CustomReactions
 | 
			
		||||
        private readonly PermissionService _perms;
 | 
			
		||||
        private readonly CommandHandler _cmd;
 | 
			
		||||
        private readonly BotConfig _bc;
 | 
			
		||||
        private readonly NadekoStrings _strings;
 | 
			
		||||
 | 
			
		||||
        public CustomReactionsService(PermissionService perms, DbService db, 
 | 
			
		||||
        public CustomReactionsService(PermissionService perms, DbService db, NadekoStrings strings,
 | 
			
		||||
            DiscordSocketClient client, CommandHandler cmd, BotConfig bc, IUnitOfWork uow)
 | 
			
		||||
        {
 | 
			
		||||
            _log = LogManager.GetCurrentClassLogger();
 | 
			
		||||
@@ -37,6 +38,7 @@ namespace NadekoBot.Services.CustomReactions
 | 
			
		||||
            _perms = perms;
 | 
			
		||||
            _cmd = cmd;
 | 
			
		||||
            _bc = bc;
 | 
			
		||||
            _strings = strings;
 | 
			
		||||
            
 | 
			
		||||
            var items = uow.CustomReactions.GetAll();
 | 
			
		||||
            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()));
 | 
			
		||||
@@ -109,7 +111,7 @@ namespace NadekoBot.Services.CustomReactions
 | 
			
		||||
                        {
 | 
			
		||||
                            if (pc.Verbose)
 | 
			
		||||
                            {
 | 
			
		||||
                                var returnMsg = $"Permission number #{index + 1} **{pc.Permissions[index].GetCommand(_cmd.GetPrefix(guild), sg)}** is preventing this action.";
 | 
			
		||||
                                var returnMsg = _strings.GetText("trigger", guild.Id, "Permissions".ToLowerInvariant(), index + 1, Format.Bold(pc.Permissions[index].GetCommand(_cmd.GetPrefix(guild), (SocketGuild)guild)));
 | 
			
		||||
                                try { await msg.Channel.SendErrorAsync(returnMsg).ConfigureAwait(false); } catch { }
 | 
			
		||||
                                _log.Info(returnMsg);
 | 
			
		||||
                            }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,15 +19,18 @@ namespace NadekoBot.Services.Games
 | 
			
		||||
        private readonly Logger _log;
 | 
			
		||||
        private readonly PermissionService _perms;
 | 
			
		||||
        private readonly CommandHandler _cmd;
 | 
			
		||||
        private readonly NadekoStrings _strings;
 | 
			
		||||
 | 
			
		||||
        public ConcurrentDictionary<ulong, Lazy<ChatterBotSession>> ChatterBotGuilds { get; }
 | 
			
		||||
 | 
			
		||||
        public ChatterBotService(DiscordSocketClient client, PermissionService perms, IEnumerable<GuildConfig> gcs, CommandHandler cmd)
 | 
			
		||||
        public ChatterBotService(DiscordSocketClient client, PermissionService perms, IEnumerable<GuildConfig> gcs, 
 | 
			
		||||
            CommandHandler cmd, NadekoStrings strings)
 | 
			
		||||
        {
 | 
			
		||||
            _client = client;
 | 
			
		||||
            _log = LogManager.GetCurrentClassLogger();
 | 
			
		||||
            _perms = perms;
 | 
			
		||||
            _cmd = cmd;
 | 
			
		||||
            _strings = strings;
 | 
			
		||||
 | 
			
		||||
            ChatterBotGuilds = new ConcurrentDictionary<ulong, Lazy<ChatterBotSession>>(
 | 
			
		||||
                    gcs.Where(gc => gc.CleverbotEnabled)
 | 
			
		||||
@@ -102,7 +105,7 @@ namespace NadekoBot.Services.Games
 | 
			
		||||
                    if (pc.Verbose)
 | 
			
		||||
                    {
 | 
			
		||||
                        //todo move this to permissions
 | 
			
		||||
                        var returnMsg = $"Permission number #{index + 1} **{pc.Permissions[index].GetCommand(_cmd.GetPrefix(guild), sg)}** is preventing this action.";
 | 
			
		||||
                        var returnMsg = _strings.GetText("trigger", guild.Id, "Permissions".ToLowerInvariant(), index + 1, Format.Bold(pc.Permissions[index].GetCommand(_cmd.GetPrefix(guild), (SocketGuild)guild)));
 | 
			
		||||
                        try { await usrMsg.Channel.SendErrorAsync(returnMsg).ConfigureAwait(false); } catch { }
 | 
			
		||||
                        _log.Info(returnMsg);
 | 
			
		||||
                    }
 | 
			
		||||
 
 | 
			
		||||
@@ -20,16 +20,18 @@ namespace NadekoBot.Services.Permissions
 | 
			
		||||
        private readonly DbService _db;
 | 
			
		||||
        private readonly Logger _log;
 | 
			
		||||
        private readonly CommandHandler _cmd;
 | 
			
		||||
        private readonly NadekoStrings _strings;
 | 
			
		||||
 | 
			
		||||
        //guildid, root permission
 | 
			
		||||
        public ConcurrentDictionary<ulong, PermissionCache> Cache { get; } =
 | 
			
		||||
            new ConcurrentDictionary<ulong, PermissionCache>();
 | 
			
		||||
 | 
			
		||||
        public PermissionService(DiscordSocketClient client, DbService db, BotConfig bc, CommandHandler cmd)
 | 
			
		||||
        public PermissionService(DiscordSocketClient client, DbService db, BotConfig bc, CommandHandler cmd, NadekoStrings strings)
 | 
			
		||||
        {
 | 
			
		||||
            _log = LogManager.GetCurrentClassLogger();
 | 
			
		||||
            _db = db;
 | 
			
		||||
            _cmd = cmd;
 | 
			
		||||
            _strings = strings;
 | 
			
		||||
 | 
			
		||||
            var sw = Stopwatch.StartNew();
 | 
			
		||||
            if (client.ShardId == 0)
 | 
			
		||||
@@ -205,11 +207,9 @@ WHERE secondaryTargetName LIKE '.%' OR
 | 
			
		||||
                PermissionCache pc = GetCache(guild.Id);
 | 
			
		||||
                if (!resetCommand && !pc.Permissions.CheckPermissions(msg, commandName, moduleName, out int index))
 | 
			
		||||
                {
 | 
			
		||||
                    var returnMsg = $"Permission number #{index + 1} **{pc.Permissions[index].GetCommand(_cmd.GetPrefix(guild), (SocketGuild)guild)}** is preventing this action.";
 | 
			
		||||
                    if (pc.Verbose)
 | 
			
		||||
                        try { await channel.SendErrorAsync(returnMsg).ConfigureAwait(false); } catch { }
 | 
			
		||||
                        try { await channel.SendErrorAsync(_strings.GetText("trigger", guild.Id, "Permissions".ToLowerInvariant(), index + 1, Format.Bold(pc.Permissions[index].GetCommand(_cmd.GetPrefix(guild), (SocketGuild)guild)))).ConfigureAwait(false); } catch { }
 | 
			
		||||
                    return true;
 | 
			
		||||
                    //return new ExecuteCommandResult(cmd, pc, SearchResult.FromError(CommandError.Exception, returnMsg));
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -222,7 +222,6 @@ WHERE secondaryTargetName LIKE '.%' OR
 | 
			
		||||
                        if (pc.Verbose)
 | 
			
		||||
                            try { await channel.SendErrorAsync(returnMsg).ConfigureAwait(false); } catch { }
 | 
			
		||||
                        return true;
 | 
			
		||||
                        //return new ExecuteCommandResult(cmd, pc, SearchResult.FromError(CommandError.Exception, $"You need the **{pc.PermRole}** role in order to use permission commands."));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -154,6 +154,7 @@
 | 
			
		||||
  "administration_old_topic": "Old topic",
 | 
			
		||||
  "administration_perms": "Error. Most likely I don't have sufficient permissions.",
 | 
			
		||||
  "permissions_perms_reset": "Permissions for this server are reset.",
 | 
			
		||||
  "permissions_trigger": "Permission number #{0} {1} is preventing this action.",
 | 
			
		||||
  "administration_prot_active": "Active protections",
 | 
			
		||||
  "administration_prot_disable": "{0} has been **disabled** on this server.",
 | 
			
		||||
  "administration_prot_enable": "{0} Enabled",
 | 
			
		||||
@@ -446,7 +447,7 @@
 | 
			
		||||
  "music_skipped_to": "Skipped to `{0}:{1}`",
 | 
			
		||||
  "music_songs_shuffled": "Songs shuffled",
 | 
			
		||||
  "music_song_moved": "Song moved",
 | 
			
		||||
  "music_song_not_found":  "No song found.",
 | 
			
		||||
  "music_song_not_found": "No song found.",
 | 
			
		||||
  "music_time_format": "{0}h {1}m {2}s",
 | 
			
		||||
  "music_to_position": "To position",
 | 
			
		||||
  "music_unlimited": "unlimited",
 | 
			
		||||
@@ -523,7 +524,7 @@
 | 
			
		||||
  "searches_cost": "Cost",
 | 
			
		||||
  "searches_date": "Date",
 | 
			
		||||
  "searches_define": "Define:",
 | 
			
		||||
  "searches_define_unknown":  "Can't find the definition for that term.",
 | 
			
		||||
  "searches_define_unknown": "Can't find the definition for that term.",
 | 
			
		||||
  "searches_dropped": "Dropped",
 | 
			
		||||
  "searches_episodes": "Episodes",
 | 
			
		||||
  "searches_error_occured": "Error occurred.",
 | 
			
		||||
@@ -534,7 +535,7 @@
 | 
			
		||||
  "searches_hashtag_error": "Failed finding a definition for that tag.",
 | 
			
		||||
  "searches_height_weight": "Height/Weight",
 | 
			
		||||
  "searches_height_weight_val": "{0}m/{1}kg",
 | 
			
		||||
  "searches_hex_invalid":  "Invalid color specified.",
 | 
			
		||||
  "searches_hex_invalid": "Invalid color specified.",
 | 
			
		||||
  "searches_humidity": "Humidity",
 | 
			
		||||
  "searches_image_search_for": "Image search for:",
 | 
			
		||||
  "searches_imdb_fail": "Failed to find that movie.",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user