dshellInterpreter 0.2.16.2__py3-none-any.whl → 0.2.17.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dshellInterpreter might be problematic. Click here for more details.
- Dshell/DISCORD_COMMANDS/utils/utils_permissions.py +4 -1
- Dshell/_DshellInterpreteur/dshell_interpreter.py +12 -2
- {dshellinterpreter-0.2.16.2.dist-info → dshellinterpreter-0.2.17.1.dist-info}/METADATA +1 -1
- {dshellinterpreter-0.2.16.2.dist-info → dshellinterpreter-0.2.17.1.dist-info}/RECORD +7 -7
- {dshellinterpreter-0.2.16.2.dist-info → dshellinterpreter-0.2.17.1.dist-info}/WHEEL +0 -0
- {dshellinterpreter-0.2.16.2.dist-info → dshellinterpreter-0.2.17.1.dist-info}/licenses/LICENSE +0 -0
- {dshellinterpreter-0.2.16.2.dist-info → dshellinterpreter-0.2.17.1.dist-info}/top_level.txt +0 -0
|
@@ -63,7 +63,10 @@ class DshellPermissions:
|
|
|
63
63
|
for role_id in (
|
|
64
64
|
self.target['roles'] if isinstance(self.target['roles'], ListNode) else [
|
|
65
65
|
self.target['roles']]): # allow a single ID
|
|
66
|
-
|
|
66
|
+
if role_id == guild.id: # @everyone role
|
|
67
|
+
role = guild.default_role
|
|
68
|
+
else:
|
|
69
|
+
role = self.get_role(guild, role_id)
|
|
67
70
|
permissions[role] = PermissionOverwrite.from_pair(
|
|
68
71
|
allow=Permissions(permissions=self.target.get('allow', 0)),
|
|
69
72
|
deny=Permissions(permissions=self.target.get('deny', 0))
|
|
@@ -28,13 +28,19 @@ class DshellInterpreteur:
|
|
|
28
28
|
Make what you want with Dshell code to interact with Discord !
|
|
29
29
|
"""
|
|
30
30
|
|
|
31
|
-
def __init__(self, code: str, ctx: context,
|
|
31
|
+
def __init__(self, code: str, ctx: context,
|
|
32
|
+
debug: bool = False,
|
|
33
|
+
vars: Optional[str] = None,
|
|
34
|
+
vars_env: Optional[dict[str, Any]] = None):
|
|
32
35
|
"""
|
|
33
36
|
Interpreter Dshell code
|
|
34
37
|
:param code: The code to interpret. Each line must end with a newline character, except SEPARATOR and SUB_SEPARATOR tokens.
|
|
35
38
|
:param ctx: The context in which the code is executed. It can be a Discord bot, a message, or a channel.
|
|
36
|
-
:param debug: If True, prints the AST of the code.
|
|
39
|
+
:param debug: If True, prints the AST of the code and put the ctx to None.
|
|
37
40
|
:param vars: Optional dictionary of variables to initialize in the interpreter's environment.
|
|
41
|
+
:param vars_env: Optional dictionary of additional environment variables to add to the interpreter's environment.
|
|
42
|
+
|
|
43
|
+
Note: __message_before__ (message content before edit) can be overwritten by vars_env parameter.
|
|
38
44
|
"""
|
|
39
45
|
self.ast: list[ASTNode] = parse(DshellTokenizer(code).start(), StartNode([]))[0]
|
|
40
46
|
message = ctx.message if isinstance(ctx, Interaction) else ctx
|
|
@@ -50,6 +56,8 @@ class DshellInterpreteur:
|
|
|
50
56
|
'__author_id__': message.author.id,
|
|
51
57
|
|
|
52
58
|
'__message__': message.content,
|
|
59
|
+
'__message_author__': message.author.id,
|
|
60
|
+
'__message_before__': message.content, # same as __message__, but before edit. Can be overwritten by add vars_env parameter
|
|
53
61
|
'__message_content__': message.content,
|
|
54
62
|
'__message_id__': message.id,
|
|
55
63
|
'__message_url__': message.jump_url if hasattr(message, 'jump_url') else None,
|
|
@@ -81,6 +89,8 @@ class DshellInterpreteur:
|
|
|
81
89
|
'__guild_channels_count__': len(message.channel.guild.channels),
|
|
82
90
|
|
|
83
91
|
} if message is not None and not debug else {} # {} is used in debug mode, when ctx is None
|
|
92
|
+
if vars_env is not None: # add the variables to the environment
|
|
93
|
+
self.env.update(vars_env)
|
|
84
94
|
self.vars = vars if vars is not None else ''
|
|
85
95
|
self.ctx: context = ctx
|
|
86
96
|
if debug:
|
|
@@ -12,10 +12,10 @@ Dshell/DISCORD_COMMANDS/utils/utils_global.py,sha256=48WpW4Vkdz1ITjCQzmnqKej-1kE
|
|
|
12
12
|
Dshell/DISCORD_COMMANDS/utils/utils_list.py,sha256=zqImMWvD-1UnbPP1TZewnvZpq7qs1sOTT1YhbJ5I8h8,3160
|
|
13
13
|
Dshell/DISCORD_COMMANDS/utils/utils_member.py,sha256=1EoHooxwijc7AFJGnuae3ccjQk0x69MELtZ5ES5abLY,1165
|
|
14
14
|
Dshell/DISCORD_COMMANDS/utils/utils_message.py,sha256=cQvJ15f49ddOjybARwkJKNFe3ITYQciF-pZHERFPkr0,2964
|
|
15
|
-
Dshell/DISCORD_COMMANDS/utils/utils_permissions.py,sha256=
|
|
15
|
+
Dshell/DISCORD_COMMANDS/utils/utils_permissions.py,sha256=Gi6vpCA2yXUZ20OCay5dkX6HeN4LglVROwcvTWVCsKg,3600
|
|
16
16
|
Dshell/DISCORD_COMMANDS/utils/utils_thread.py,sha256=tVl4msEwrWHY-0AytI6eY3JSs-eIFUigDSJfK9mT1ww,1457
|
|
17
17
|
Dshell/_DshellInterpreteur/__init__.py,sha256=xy5-J-R3YmY99JF3NBHTRRLsComFxpjnCA5xacISctU,35
|
|
18
|
-
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=
|
|
18
|
+
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=mO2UCzcc7-6IFtmo_63U_G6NI1RzMvKGbpE0yfgjOd0,29321
|
|
19
19
|
Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZxC4,56
|
|
20
20
|
Dshell/_DshellParser/ast_nodes.py,sha256=S2byqd02RMC-ILCX-ZS8zhwOBIBtvMtQ4ESnljjsWmA,18748
|
|
21
21
|
Dshell/_DshellParser/dshell_parser.py,sha256=KD2ZbKYa1nnvroKmN8fIRD2exXre54Qx_roEBrTV7Mo,18588
|
|
@@ -23,8 +23,8 @@ Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8q
|
|
|
23
23
|
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=crzX16IbcYCVqxgzz3NvN0-FzKtBjZcZQvtHqdxhDGk,6787
|
|
24
24
|
Dshell/_DshellTokenizer/dshell_token_type.py,sha256=gYIb2XN2YcgeRgmar_rBDS5CGmwfmxihu8mOW_d6lbE,1533
|
|
25
25
|
Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=AJnUocD6hbU6wvjRAN5uDha5QQieTwXlHzZVtgRGaZQ,7307
|
|
26
|
-
dshellinterpreter-0.2.
|
|
27
|
-
dshellinterpreter-0.2.
|
|
28
|
-
dshellinterpreter-0.2.
|
|
29
|
-
dshellinterpreter-0.2.
|
|
30
|
-
dshellinterpreter-0.2.
|
|
26
|
+
dshellinterpreter-0.2.17.1.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
|
|
27
|
+
dshellinterpreter-0.2.17.1.dist-info/METADATA,sha256=zTtAbaovo4DYxGON4zaqLWFAx9Ai7pZCMZS-hI2dURE,1151
|
|
28
|
+
dshellinterpreter-0.2.17.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
29
|
+
dshellinterpreter-0.2.17.1.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
|
|
30
|
+
dshellinterpreter-0.2.17.1.dist-info/RECORD,,
|
|
File without changes
|
{dshellinterpreter-0.2.16.2.dist-info → dshellinterpreter-0.2.17.1.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|