mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-04 00:34:26 -05:00 
			
		
		
		
	Added DmHelpTextKeywords to data/bot.yml
- Bot now sends dm help text ONLY if the message contains one of the keywords specified - If no keywords are specified, bot will reply to every DM (like before) - Fixed several commands which used error color for success confirmation messages
This commit is contained in:
		@@ -12,7 +12,7 @@ namespace NadekoBot.Common.Configs
 | 
			
		||||
    public sealed partial class BotConfig : ICloneable<BotConfig>
 | 
			
		||||
    {
 | 
			
		||||
        [Comment(@"DO NOT CHANGE")]
 | 
			
		||||
        public int Version { get; set; }
 | 
			
		||||
        public int Version { get; set; } = 2;
 | 
			
		||||
 | 
			
		||||
        [Comment(@"Most commands, when executed, have a small colored line
 | 
			
		||||
next to the response. The color depends whether the command
 | 
			
		||||
@@ -48,6 +48,11 @@ they will receive this message. Leave empty for no response. The string which wi
 | 
			
		||||
Supports embeds. How it looks: https://puu.sh/B0BLV.png")]
 | 
			
		||||
        [YamlMember(ScalarStyle = ScalarStyle.Literal)]
 | 
			
		||||
        public string DmHelpText { get; set; }
 | 
			
		||||
        
 | 
			
		||||
        [Comment(@"Only users who send a DM to the bot containing one of the specified words will get a DmHelpText response.
 | 
			
		||||
Case insensitive.
 | 
			
		||||
Leave empty to reply with DmHelpText to every DM.")]
 | 
			
		||||
        public List<string> DmHelpTextKeywords { get; set; }
 | 
			
		||||
 | 
			
		||||
        [Comment(@"This is the response for the .h command")]
 | 
			
		||||
        [YamlMember(ScalarStyle = ScalarStyle.Literal)]
 | 
			
		||||
@@ -89,7 +94,6 @@ See RotatingStatuses submodule in Administration.")]
 | 
			
		||||
 | 
			
		||||
        public BotConfig()
 | 
			
		||||
        {
 | 
			
		||||
            Version = 1;
 | 
			
		||||
            var color = new ColorConfig();
 | 
			
		||||
            Color = color;
 | 
			
		||||
            DefaultLocale = new CultureInfo("en-US");
 | 
			
		||||
@@ -127,6 +131,14 @@ See RotatingStatuses submodule in Administration.")]
 | 
			
		||||
            Prefix = ".";
 | 
			
		||||
            RotateStatuses = false;
 | 
			
		||||
            GroupGreets = false;
 | 
			
		||||
            DmHelpTextKeywords = new List<string>()
 | 
			
		||||
            {
 | 
			
		||||
                "help",
 | 
			
		||||
                "commands",
 | 
			
		||||
                "cmds",
 | 
			
		||||
                "module",
 | 
			
		||||
                "can you do"
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -88,7 +88,7 @@ namespace NadekoBot.Modules.Administration
 | 
			
		||||
                };
 | 
			
		||||
                _service.AddNewAutoCommand(cmd);
 | 
			
		||||
 | 
			
		||||
                await ReplyErrorLocalizedAsync(strs.autocmd_add(Format.Code(Format.Sanitize(cmdText)), cmd.Interval));
 | 
			
		||||
                await ReplyConfirmLocalizedAsync(strs.autocmd_add(Format.Code(Format.Sanitize(cmdText)), cmd.Interval));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            [NadekoCommand, Aliases]
 | 
			
		||||
@@ -226,7 +226,7 @@ namespace NadekoBot.Modules.Administration
 | 
			
		||||
                if (enabled)
 | 
			
		||||
                    await ReplyConfirmLocalizedAsync(strs.fwdm_start).ConfigureAwait(false);
 | 
			
		||||
                else
 | 
			
		||||
                    await ReplyConfirmLocalizedAsync(strs.fwdm_stop).ConfigureAwait(false);
 | 
			
		||||
                    await ReplyPendingLocalizedAsync(strs.fwdm_stop).ConfigureAwait(false);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            [NadekoCommand, Aliases]
 | 
			
		||||
@@ -238,7 +238,7 @@ namespace NadekoBot.Modules.Administration
 | 
			
		||||
                if (enabled)
 | 
			
		||||
                    await ReplyConfirmLocalizedAsync(strs.fwall_start).ConfigureAwait(false);
 | 
			
		||||
                else
 | 
			
		||||
                    await ReplyConfirmLocalizedAsync(strs.fwall_stop).ConfigureAwait(false);
 | 
			
		||||
                    await ReplyPendingLocalizedAsync(strs.fwall_stop).ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@@ -376,7 +376,7 @@ namespace NadekoBot.Modules.Administration
 | 
			
		||||
                var curUser = await ctx.Guild.GetCurrentUserAsync().ConfigureAwait(false);
 | 
			
		||||
                await curUser.ModifyAsync(u => u.Nickname = newNick).ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
                await ReplyErrorLocalizedAsync(strs.bot_nick(Format.Bold(newNick) ?? "-"));
 | 
			
		||||
                await ReplyConfirmLocalizedAsync(strs.bot_nick(Format.Bold(newNick) ?? "-"));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            [NadekoCommand, Aliases]
 | 
			
		||||
@@ -395,7 +395,7 @@ namespace NadekoBot.Modules.Administration
 | 
			
		||||
                
 | 
			
		||||
                await gu.ModifyAsync(u => u.Nickname = newNick).ConfigureAwait(false);
 | 
			
		||||
 | 
			
		||||
                await ReplyErrorLocalizedAsync(strs.user_nick(Format.Bold(gu.ToString()), Format.Bold(newNick) ?? "-"));
 | 
			
		||||
                await ReplyConfirmLocalizedAsync(strs.user_nick(Format.Bold(gu.ToString()), Format.Bold(newNick) ?? "-"));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            [NadekoCommand, Aliases]
 | 
			
		||||
@@ -496,7 +496,7 @@ namespace NadekoBot.Modules.Administration
 | 
			
		||||
            public async Task ImagesReload()
 | 
			
		||||
            {
 | 
			
		||||
                await _service.ReloadImagesAsync();
 | 
			
		||||
                await ReplyErrorLocalizedAsync(strs.images_loading);
 | 
			
		||||
                await ReplyConfirmLocalizedAsync(strs.images_loading);
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            [NadekoCommand, Aliases]
 | 
			
		||||
 
 | 
			
		||||
@@ -44,6 +44,11 @@ namespace NadekoBot.Modules.Help.Services
 | 
			
		||||
            {
 | 
			
		||||
                if (string.IsNullOrWhiteSpace(settings.DmHelpText) || settings.DmHelpText == "-")
 | 
			
		||||
                    return Task.CompletedTask;
 | 
			
		||||
                
 | 
			
		||||
                // only send dm help text if it contains one of the keywords, if they're specified
 | 
			
		||||
                // if they're not, then reply to every DM
 | 
			
		||||
                if (settings.DmHelpTextKeywords.Any() && !settings.DmHelpTextKeywords.Any(k => msg.Content.Contains(k)))
 | 
			
		||||
                    return Task.CompletedTask;
 | 
			
		||||
 | 
			
		||||
                var rep = new ReplacementBuilder()
 | 
			
		||||
                    .WithOverride("%prefix%", () => _bss.Data.Prefix)
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@ namespace NadekoBot.Modules.Xp.Services
 | 
			
		||||
 | 
			
		||||
        private void Migrate()
 | 
			
		||||
        {
 | 
			
		||||
            if (_data.Version <= 1)
 | 
			
		||||
            if (_data.Version < 2)
 | 
			
		||||
            {
 | 
			
		||||
                ModifyConfig(c =>
 | 
			
		||||
                {
 | 
			
		||||
 
 | 
			
		||||
@@ -28,19 +28,15 @@ namespace NadekoBot.Services
 | 
			
		||||
            AddParsedProp("locale", bs => bs.DefaultLocale, ConfigParsers.Culture, ConfigPrinters.Culture);
 | 
			
		||||
            AddParsedProp("prefix", bs => bs.Prefix, ConfigParsers.String, ConfigPrinters.ToString);
 | 
			
		||||
            
 | 
			
		||||
            UpdateColors();
 | 
			
		||||
            Migrate();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void UpdateColors()
 | 
			
		||||
        private void Migrate()
 | 
			
		||||
        {
 | 
			
		||||
            var ok = _data.Color.Ok;
 | 
			
		||||
            var error = _data.Color.Error;
 | 
			
		||||
            var pend = _data.Color.Pending;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        protected override void OnStateUpdate()
 | 
			
		||||
        {
 | 
			
		||||
            UpdateColors();
 | 
			
		||||
            if (_data.Version < 2)
 | 
			
		||||
            {
 | 
			
		||||
                ModifyConfig(c => c.Version = 2);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
# DO NOT CHANGE
 | 
			
		||||
version: 1
 | 
			
		||||
version: 2
 | 
			
		||||
# Most commands, when executed, have a small colored line
 | 
			
		||||
# next to the response. The color depends whether the command
 | 
			
		||||
# is completed, errored or in progress (pending)
 | 
			
		||||
@@ -28,6 +28,15 @@ forwardToAllOwners: false
 | 
			
		||||
# Supports embeds. How it looks: https://puu.sh/B0BLV.png
 | 
			
		||||
dmHelpText: |-
 | 
			
		||||
  {"description": "Type `%prefix%h` for help."}
 | 
			
		||||
# Only users who send a DM to the bot containing one of the specified words will get a DmHelpText response.
 | 
			
		||||
# Case insensitive.
 | 
			
		||||
# Leave empty to reply with DmHelpText to every DM.
 | 
			
		||||
dmHelpTextKeywords:
 | 
			
		||||
  - help
 | 
			
		||||
  - commands
 | 
			
		||||
  - cmds
 | 
			
		||||
  - module
 | 
			
		||||
  - can you do
 | 
			
		||||
# This is the response for the .h command
 | 
			
		||||
helpText: |-
 | 
			
		||||
  {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user