mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-03 16:24:27 -05:00 
			
		
		
		
	Added .expraddserver (.exas) which will server as a server-only alternative to '.exa' in case users want to override default Admin permissions with .dpo
This commit is contained in:
		@@ -1,7 +1,5 @@
 | 
				
			|||||||
#nullable disable
 | 
					#nullable disable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using Nadeko.Common;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace NadekoBot.Modules.NadekoExpressions;
 | 
					namespace NadekoBot.Modules.NadekoExpressions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[Name("Expressions")]
 | 
					[Name("Expressions")]
 | 
				
			||||||
@@ -25,15 +23,10 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
 | 
				
			|||||||
        => (ctx.Guild is null && _creds.IsOwner(ctx.User))
 | 
					        => (ctx.Guild is null && _creds.IsOwner(ctx.User))
 | 
				
			||||||
           || (ctx.Guild is not null && ((IGuildUser)ctx.User).GuildPermissions.Administrator);
 | 
					           || (ctx.Guild is not null && ((IGuildUser)ctx.User).GuildPermissions.Administrator);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [Cmd]
 | 
					    private async Task ExprAddInternalAsync(string key, string message)
 | 
				
			||||||
    public async Task ExprAdd(string key, [Leftover] string message)
 | 
					 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (string.IsNullOrWhiteSpace(message) || string.IsNullOrWhiteSpace(key))
 | 
					        if (string.IsNullOrWhiteSpace(message) || string.IsNullOrWhiteSpace(key))
 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (!AdminInGuildOrOwnerInDm())
 | 
					 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            await ReplyErrorLocalizedAsync(strs.expr_insuff_perms);
 | 
					 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -48,12 +41,43 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
 | 
				
			|||||||
                                            message.Length > 1024 ? GetText(strs.redacted_too_long) : message));
 | 
					                                            message.Length > 1024 ? GetText(strs.redacted_too_long) : message));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    [Cmd]
 | 
				
			||||||
 | 
					    [UserPerm(GuildPerm.Administrator)]
 | 
				
			||||||
 | 
					    public async Task ExprAddServer(string key, [Leftover] string message)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (string.IsNullOrWhiteSpace(message) || string.IsNullOrWhiteSpace(key))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        await ExprAddInternalAsync(key, message);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    [Cmd]
 | 
				
			||||||
 | 
					    public async Task ExprAdd(string key, [Leftover] string message)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (string.IsNullOrWhiteSpace(message) || string.IsNullOrWhiteSpace(key))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!AdminInGuildOrOwnerInDm())
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            await ReplyErrorLocalizedAsync(strs.expr_insuff_perms);
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        await ExprAddInternalAsync(key, message);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [Cmd]
 | 
					    [Cmd]
 | 
				
			||||||
    public async Task ExprEdit(kwum id, [Leftover] string message)
 | 
					    public async Task ExprEdit(kwum id, [Leftover] string message)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        var channel = ctx.Channel as ITextChannel;
 | 
					        var channel = ctx.Channel as ITextChannel;
 | 
				
			||||||
        if (string.IsNullOrWhiteSpace(message) || id < 0)
 | 
					        if (string.IsNullOrWhiteSpace(message) || id < 0)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ((channel is null && !_creds.IsOwner(ctx.User))
 | 
					        if ((channel is null && !_creds.IsOwner(ctx.User))
 | 
				
			||||||
            || (channel is not null && !((IGuildUser)ctx.User).GuildPermissions.Administrator))
 | 
					            || (channel is not null && !((IGuildUser)ctx.User).GuildPermissions.Administrator))
 | 
				
			||||||
@@ -74,7 +98,9 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
 | 
				
			|||||||
                                                message.Length > 1024 ? GetText(strs.redacted_too_long) : message));
 | 
					                                                message.Length > 1024 ? GetText(strs.redacted_too_long) : message));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
            await ReplyErrorLocalizedAsync(strs.expr_no_found_id);
 | 
					            await ReplyErrorLocalizedAsync(strs.expr_no_found_id);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [Cmd]
 | 
					    [Cmd]
 | 
				
			||||||
@@ -82,7 +108,9 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
 | 
				
			|||||||
    public async Task ExprList(int page = 1)
 | 
					    public async Task ExprList(int page = 1)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (--page < 0 || page > 999)
 | 
					        if (--page < 0 || page > 999)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var expressions = _service.GetExpressionsFor(ctx.Guild?.Id);
 | 
					        var expressions = _service.GetExpressionsFor(ctx.Guild?.Id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -153,7 +181,9 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
 | 
				
			|||||||
                                            .AddField(GetText(strs.response), ex.Response.TrimTo(1024)));
 | 
					                                            .AddField(GetText(strs.response), ex.Response.TrimTo(1024)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
            await ReplyErrorLocalizedAsync(strs.expr_no_found_id);
 | 
					            await ReplyErrorLocalizedAsync(strs.expr_no_found_id);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [Cmd]
 | 
					    [Cmd]
 | 
				
			||||||
@@ -192,7 +222,9 @@ public partial class NadekoExpressions : NadekoModule<NadekoExpressionsService>
 | 
				
			|||||||
                succ.Add(emojiStr);
 | 
					                succ.Add(emojiStr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (succ.Count >= 3)
 | 
					                if (succ.Count >= 3)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            catch { }
 | 
					            catch { }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,7 +37,7 @@ boost:
 | 
				
			|||||||
boostmsg:
 | 
					boostmsg:
 | 
				
			||||||
  - boostmsg
 | 
					  - boostmsg
 | 
				
			||||||
boostdel:
 | 
					boostdel:
 | 
				
			||||||
  - boostdel
 | 
					  - boostde
 | 
				
			||||||
logserver:
 | 
					logserver:
 | 
				
			||||||
  - logserver
 | 
					  - logserver
 | 
				
			||||||
logignore:
 | 
					logignore:
 | 
				
			||||||
@@ -1287,6 +1287,11 @@ expradd:
 | 
				
			|||||||
  - exadd
 | 
					  - exadd
 | 
				
			||||||
  - exa
 | 
					  - exa
 | 
				
			||||||
  - acr
 | 
					  - acr
 | 
				
			||||||
 | 
					expraddserver:
 | 
				
			||||||
 | 
					  - expradds
 | 
				
			||||||
 | 
					  - exadds
 | 
				
			||||||
 | 
					  - exas
 | 
				
			||||||
 | 
					  - expraddserver
 | 
				
			||||||
exprlist:
 | 
					exprlist:
 | 
				
			||||||
  - exprlist
 | 
					  - exprlist
 | 
				
			||||||
  - exl
 | 
					  - exl
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
# DO NOT CHANGE
 | 
					# DO NOT CHANGE
 | 
				
			||||||
version: 3
 | 
					version: 4
 | 
				
			||||||
# Most commands, when executed, have a small colored line
 | 
					# Most commands, when executed, have a small colored line
 | 
				
			||||||
# next to the response. The color depends whether the command
 | 
					# next to the response. The color depends whether the command
 | 
				
			||||||
# is completed, errored or in progress (pending)
 | 
					# is completed, errored or in progress (pending)
 | 
				
			||||||
@@ -18,6 +18,8 @@ defaultLocale: en-US
 | 
				
			|||||||
# Style in which executed commands will show up in the console.
 | 
					# Style in which executed commands will show up in the console.
 | 
				
			||||||
# Allowed values: Simple, Normal, None
 | 
					# Allowed values: Simple, Normal, None
 | 
				
			||||||
consoleOutputType: Normal
 | 
					consoleOutputType: Normal
 | 
				
			||||||
 | 
					# Whether the bot will check for new releases every hour
 | 
				
			||||||
 | 
					checkForUpdates: true
 | 
				
			||||||
# Do you want any messages sent by users in Bot's DM to be forwarded to the owner(s)?
 | 
					# Do you want any messages sent by users in Bot's DM to be forwarded to the owner(s)?
 | 
				
			||||||
forwardMessages: false
 | 
					forwardMessages: false
 | 
				
			||||||
# Do you want the message to be forwarded only to the first owner specified in the list of owners (in creds.yml),
 | 
					# Do you want the message to be forwarded only to the first owner specified in the list of owners (in creds.yml),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -197,7 +197,11 @@ iamnot:
 | 
				
			|||||||
  args:
 | 
					  args:
 | 
				
			||||||
    - "Gamer"
 | 
					    - "Gamer"
 | 
				
			||||||
expradd:
 | 
					expradd:
 | 
				
			||||||
  desc: "Add an expression with a trigger and a response. Running this command in server requires the Administration permission. Running this command in DM is Bot Owner only and adds a new global expression. Guide here: <https://nadekobot.readthedocs.io/en/latest/custom-reactions/>"
 | 
					  desc: "Add an expression with a trigger and a response. Bot will post a response whenever someone types the trigger word.  Running this command in server requires the Administration permission. Running this command in DM is Bot Owner only and adds a new global expression. Guide here: <https://nadekobot.readthedocs.io/en/latest/custom-reactions/>"
 | 
				
			||||||
 | 
					  args:
 | 
				
			||||||
 | 
					    - "\"hello\" Hi there %user.mention%"
 | 
				
			||||||
 | 
					expraddserver:
 | 
				
			||||||
 | 
					  desc: "Add an expression with a trigger and a response in this server. Bot will post a response whenever someone types the trigger word. Guide here: <https://nadekobot.readthedocs.io/en/latest/custom-reactions/>"
 | 
				
			||||||
  args:
 | 
					  args:
 | 
				
			||||||
    - "\"hello\" Hi there %user.mention%"
 | 
					    - "\"hello\" Hi there %user.mention%"
 | 
				
			||||||
exprlist:
 | 
					exprlist:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user