dshellInterpreter 0.1.24__py3-none-any.whl → 0.1.26__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/dshell_message.py +3 -3
- Dshell/_DshellInterpreteur/dshell_interpreter.py +21 -5
- {dshellinterpreter-0.1.24.dist-info → dshellinterpreter-0.1.26.dist-info}/METADATA +1 -1
- {dshellinterpreter-0.1.24.dist-info → dshellinterpreter-0.1.26.dist-info}/RECORD +7 -7
- {dshellinterpreter-0.1.24.dist-info → dshellinterpreter-0.1.26.dist-info}/WHEEL +0 -0
- {dshellinterpreter-0.1.24.dist-info → dshellinterpreter-0.1.26.dist-info}/licenses/LICENSE +0 -0
- {dshellinterpreter-0.1.24.dist-info → dshellinterpreter-0.1.26.dist-info}/top_level.txt +0 -0
|
@@ -42,17 +42,17 @@ async def dshell_send_message(ctx: Message, message=None, delete=None, channel=N
|
|
|
42
42
|
return sended_message.id
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
async def dshell_delete_message(ctx: Message, message, reason=None, delay=0):
|
|
45
|
+
async def dshell_delete_message(ctx: Message, message=None, reason=None, delay=0):
|
|
46
46
|
"""
|
|
47
47
|
Deletes a message
|
|
48
48
|
"""
|
|
49
49
|
|
|
50
|
-
delete_message = ctx.channel.get_partial_message(message) # builds a reference to the message (even if it doesn't exist)
|
|
50
|
+
delete_message = ctx if message is None else ctx.channel.get_partial_message(message) # builds a reference to the message (even if it doesn't exist)
|
|
51
51
|
|
|
52
52
|
if delay > 3600:
|
|
53
53
|
raise Exception(f'The message deletion delay is too long! ({delay} seconds)')
|
|
54
54
|
|
|
55
|
-
await delete_message.delete(delay=delay, reason=reason)
|
|
55
|
+
#await delete_message.delete(delay=delay, reason=reason)
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
async def dshell_purge_message(ctx: Message, message_number, channel=None, reason=None):
|
|
@@ -167,14 +167,27 @@ def get_params(node: ParamNode, interpreter: DshellInterpreteur) -> dict[str, An
|
|
|
167
167
|
regrouped_args: dict[str, list] = regroupe_commandes(node.body, interpreter)[
|
|
168
168
|
0] # just regroup the commands, no need to do anything else
|
|
169
169
|
regrouped_args.pop('*', ())
|
|
170
|
+
englobe_args = regrouped_args.pop('--*', {}) # get the arguments that are not mandatory
|
|
170
171
|
obligate = [i for i in regrouped_args.keys() if regrouped_args[i] == '*'] # get the obligatory parameters
|
|
171
172
|
|
|
173
|
+
|
|
172
174
|
g: list[list[Token]] = DshellTokenizer(interpreter.vars).start()
|
|
173
175
|
env_give_variables = regroupe_commandes(g[0], interpreter)[0] if g else {}
|
|
174
176
|
|
|
175
177
|
gived_variables = env_give_variables.pop('*', ()) # get the variables given in the environment
|
|
178
|
+
englobe_gived_variables: dict = env_give_variables.pop('--*', {}) # get the variables given in the environment that are not mandatory
|
|
179
|
+
|
|
176
180
|
for key, value in zip(regrouped_args.keys(), gived_variables):
|
|
177
181
|
regrouped_args[key] = value
|
|
182
|
+
gived_variables.pop(0)
|
|
183
|
+
|
|
184
|
+
if len(gived_variables) > 0:
|
|
185
|
+
for key in englobe_args.keys():
|
|
186
|
+
regrouped_args[key] = ' '.join([str(i) for i in gived_variables])
|
|
187
|
+
|
|
188
|
+
for key, englobe_gived_key, englobe_gived_value in zip(englobe_args.keys(), englobe_gived_variables.keys(), englobe_gived_variables.values()):
|
|
189
|
+
if key == englobe_gived_key:
|
|
190
|
+
regrouped_args[key] = englobe_gived_value
|
|
178
191
|
|
|
179
192
|
for key, value in env_give_variables.items():
|
|
180
193
|
if key in regrouped_args:
|
|
@@ -251,13 +264,13 @@ async def call_function(function: Callable, args: ArgsCommandNode, interpreter:
|
|
|
251
264
|
|
|
252
265
|
# conversion des args en valeurs Python
|
|
253
266
|
absolute_args = reformatted.pop('*', list())
|
|
267
|
+
englobe_args = reformatted.pop('--*', list())
|
|
254
268
|
|
|
255
269
|
reformatted: dict[str, Token]
|
|
256
270
|
|
|
257
271
|
absolute_args.insert(0, interpreter.ctx)
|
|
258
|
-
keyword_args =
|
|
259
|
-
|
|
260
|
-
}
|
|
272
|
+
keyword_args = reformatted.copy()
|
|
273
|
+
keyword_args.update(englobe_args)
|
|
261
274
|
return await function(*absolute_args, **keyword_args)
|
|
262
275
|
|
|
263
276
|
|
|
@@ -273,7 +286,8 @@ def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur) -> li
|
|
|
273
286
|
:param body: The list of tokens to group.
|
|
274
287
|
:param interpreter: The Dshell interpreter instance.
|
|
275
288
|
"""
|
|
276
|
-
tokens = {'*': []
|
|
289
|
+
tokens = {'*': [],
|
|
290
|
+
'--*': {}} # tokens to return
|
|
277
291
|
current_arg = '*' # the argument keys are the types they belong to. '*' is for all arguments not explicitly specified by a separator and an IDENT
|
|
278
292
|
n = len(body)
|
|
279
293
|
list_tokens: list[dict] = [tokens]
|
|
@@ -301,7 +315,7 @@ def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur) -> li
|
|
|
301
315
|
body[i + 2].type == DTT.IDENT and
|
|
302
316
|
body[i + 3].type == DTT.ENGLOBE_SEPARATOR):
|
|
303
317
|
current_arg = body[i + 2].value # change the current argument
|
|
304
|
-
tokens[current_arg] = body[i + 3].value
|
|
318
|
+
tokens['--*'][current_arg] = body[i + 3].value
|
|
305
319
|
i += 4
|
|
306
320
|
|
|
307
321
|
else:
|
|
@@ -320,12 +334,14 @@ def build_embed(body: list[Token], fields: list[FieldEmbedNode], interpreter: Ds
|
|
|
320
334
|
"""
|
|
321
335
|
args_main_embed: dict[str, list[Any]] = regroupe_commandes(body, interpreter)[0]
|
|
322
336
|
args_main_embed.pop('*') # remove unspecified parameters for the embed
|
|
337
|
+
args_main_embed.pop('--*')
|
|
323
338
|
args_main_embed: dict[str, Token] # specify what it contains from now on
|
|
324
339
|
|
|
325
340
|
args_fields: list[dict[str, Token]] = []
|
|
326
341
|
for field in fields: # do the same for the fields
|
|
327
342
|
a = regroupe_commandes(field.body, interpreter)[0]
|
|
328
343
|
a.pop('*')
|
|
344
|
+
a.pop('--*')
|
|
329
345
|
a: dict[str, Token]
|
|
330
346
|
args_fields.append(a)
|
|
331
347
|
|
|
@@ -2,9 +2,9 @@ Dshell/__init__.py,sha256=UPvXnewe_8FX9aoevMA78UN1k8AY-u8LTY3vEVxaDxw,72
|
|
|
2
2
|
Dshell/DISCORD_COMMANDS/__init__.py,sha256=unbZE4sxFCbUQ4Qptr1BhWu-nwhvI2oRzcDLtRmX6Ug,92
|
|
3
3
|
Dshell/DISCORD_COMMANDS/dshell_channel.py,sha256=_qHfhVaeXLQMI926AJI3uYpjDXxVNF3sZ84EwWU-jz0,6450
|
|
4
4
|
Dshell/DISCORD_COMMANDS/dshell_member.py,sha256=4cmpcu9RGHVUOGcF9pSnnxh7kEJQWAel4BBQ6Vicvbs,3126
|
|
5
|
-
Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=
|
|
5
|
+
Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=18wfw5ndTdGko_Q_XOxbxPTLGzlyXtD9oxpwIavXyxw,4461
|
|
6
6
|
Dshell/_DshellInterpreteur/__init__.py,sha256=xy5-J-R3YmY99JF3NBHTRRLsComFxpjnCA5xacISctU,35
|
|
7
|
-
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=
|
|
7
|
+
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=qlTsGX2iPQDxAjfVHs9HTRILrw0OgcwsRhYGq6C8BcY,20714
|
|
8
8
|
Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZxC4,56
|
|
9
9
|
Dshell/_DshellParser/ast_nodes.py,sha256=-zFmSeb6FnvcXd2gB3koy93apVJ-PiCY8PTUFj-_bG8,15307
|
|
10
10
|
Dshell/_DshellParser/dshell_parser.py,sha256=jCnwxY_J-_u1W_tEotQznp4_Y0aeAH4pTcPl6_Fx9f8,15525
|
|
@@ -12,8 +12,8 @@ Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8q
|
|
|
12
12
|
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=10VctszIRg8AX5Nsr7kwRIjdwzUgTfrrJYbD7QfYR5s,4253
|
|
13
13
|
Dshell/_DshellTokenizer/dshell_token_type.py,sha256=pWzvmj6EFGkDwNHooOAjdyysi1vZRVEostFIZSW1Ais,1483
|
|
14
14
|
Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=a4HJdeIT3HP0a5ekUwq5Nb9Wohnjk5A44yGEneCUBjQ,7020
|
|
15
|
-
dshellinterpreter-0.1.
|
|
16
|
-
dshellinterpreter-0.1.
|
|
17
|
-
dshellinterpreter-0.1.
|
|
18
|
-
dshellinterpreter-0.1.
|
|
19
|
-
dshellinterpreter-0.1.
|
|
15
|
+
dshellinterpreter-0.1.26.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
|
|
16
|
+
dshellinterpreter-0.1.26.dist-info/METADATA,sha256=Qjpu-A6vBrirEmIB96XkRGertXahqp7cba1ruZwUv8I,1096
|
|
17
|
+
dshellinterpreter-0.1.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
18
|
+
dshellinterpreter-0.1.26.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
|
|
19
|
+
dshellinterpreter-0.1.26.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|