dshellInterpreter 0.2.13.3__py3-none-any.whl → 0.2.13.5__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.

@@ -311,7 +311,7 @@ async def call_function(function: Callable, args: ArgsCommandNode, interpreter:
311
311
  return await function(*absolute_args, **keyword_args)
312
312
 
313
313
 
314
- def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur) -> list[dict[str, list[Any]]]:
314
+ def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur, normalise: bool = False) -> list[dict[str, list[Any]]]:
315
315
  """
316
316
  Groups the command arguments in the form of a python dictionary.
317
317
  Note that you can specify the parameter you wish to pass via -- followed by the parameter name. But this is not mandatory!
@@ -322,6 +322,7 @@ def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur) -> li
322
322
 
323
323
  :param body: The list of tokens to group.
324
324
  :param interpreter: The Dshell interpreter instance.
325
+ :param normalise: If True, normalises the arguments (make value lowercase).
325
326
  """
326
327
  tokens = {'*': [],
327
328
  '--*': {}} # tokens to return
@@ -332,6 +333,9 @@ def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur) -> li
332
333
  i = 0
333
334
  while i < n:
334
335
 
336
+ if normalise and body[i].type == DTT.STR:
337
+ body[i].value = body[i].value.lower()
338
+
335
339
  if body[i].type == DTT.SEPARATOR and body[
336
340
  i + 1].type == DTT.IDENT: # Check if it's a separator and if the next token is an IDENT
337
341
  current_arg = body[i + 1].value # change the current argument. It will be impossible to return to '*'
@@ -419,12 +423,11 @@ def build_ui(ui_node: UiNode, interpreter: DshellInterpreteur) -> EasyModifiedVi
419
423
  view = EasyModifiedViews()
420
424
 
421
425
  for component in ui_node.buttons:
422
- b = Button
423
- args_button: dict[str, list[Any]] = regroupe_commandes(component.body, interpreter)[0]
426
+ args_button: dict[str, list[Any]] = regroupe_commandes(component.body, interpreter, normalise=True)[0]
424
427
  args_button.pop('--*', ())
425
428
  code = args_button.pop('code', None)
426
429
  args = args_button.pop('*', ())
427
- b(*args, **args_button)
430
+ b = Button(*args, **args_button)
428
431
 
429
432
  custom_id = ''.join(choice(ascii_letters + digits) for _ in range(20))
430
433
  b.custom_id = custom_id
@@ -435,6 +438,14 @@ def build_ui(ui_node: UiNode, interpreter: DshellInterpreteur) -> EasyModifiedVi
435
438
  return view
436
439
 
437
440
  async def ui_button_callback(button, interaction, data):
441
+ """
442
+ Callback for UI buttons.
443
+ Executes the code associated with the button.
444
+ :param button:
445
+ :param interaction:
446
+ :param data:
447
+ :return:
448
+ """
438
449
  code = data.pop('code', None)
439
450
  local_env = {}
440
451
  if code is not None:
@@ -457,7 +468,7 @@ async def ui_button_callback(button, interaction, data):
457
468
  '__private_channel__': isinstance(interaction.channel, PrivateChannel),
458
469
  }
459
470
  local_env.update(data)
460
- x = DshellInterpreteur(code, interaction, debug=False)
471
+ x = DshellInterpreteur(code, interaction.message, debug=False)
461
472
  x.env.update(local_env)
462
473
  await x.execute()
463
474
 
@@ -498,12 +498,11 @@ class UiNode(ASTNode):
498
498
  This is used to define UI elements for commands in Dshell.
499
499
  """
500
500
 
501
- def __init__(self, body, buttons: Optional[list[UiButtonNode]] = None,
501
+ def __init__(self, buttons: Optional[list[UiButtonNode]] = None,
502
502
  selects: Optional[list[UiSelectNode]] = None):
503
503
  """
504
504
  :param body: list of tokens representing the UI component
505
505
  """
506
- self.body = body
507
506
  self.buttons = buttons or []
508
507
  self.selects = selects or []
509
508
 
@@ -205,15 +205,13 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
205
205
  if not isinstance(last_block, UiNode):
206
206
  raise SyntaxError(f'[BUTTON] No UI open on line {first_token_line.position} !')
207
207
  button_node = UiButtonNode(tokens_by_line[1:])
208
- last_block.body.append(button_node)
209
- pointeur += 1
208
+ last_block.buttons.append(button_node)
210
209
 
211
210
  elif first_token_line.value == 'select':
212
211
  if not isinstance(last_block, UiNode):
213
212
  raise SyntaxError(f'[SELECT] No UI open on line {first_token_line.position} !')
214
213
  select_node = UiSelectNode(tokens_by_line[1:])
215
- last_block.body.append(select_node)
216
- pointeur += 1
214
+ last_block.selects.append(select_node)
217
215
 
218
216
  ############################## AUTRE ##############################
219
217
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.2.13.3
3
+ Version: 0.2.13.5
4
4
  Summary: A Discord bot interpreter for creating custom commands and automations.
5
5
  Home-page: https://github.com/BOXERRMD/Dshell_Interpreter
6
6
  Author: Chronos
@@ -10,16 +10,16 @@ Dshell/DISCORD_COMMANDS/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
10
10
  Dshell/DISCORD_COMMANDS/utils/utils_message.py,sha256=Pn0ljyeCvRfY4tlWHrSbIsxSFZZ5J4lDaeVme3WHp9o,1239
11
11
  Dshell/DISCORD_COMMANDS/utils/utils_thread.py,sha256=tVl4msEwrWHY-0AytI6eY3JSs-eIFUigDSJfK9mT1ww,1457
12
12
  Dshell/_DshellInterpreteur/__init__.py,sha256=xy5-J-R3YmY99JF3NBHTRRLsComFxpjnCA5xacISctU,35
13
- Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=rHRCoLvT6J1mtyYm9jGH5XlbRAjU7pawAVxRv6a4B9k,25956
13
+ Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=E2NA5SpnbdB-o1MOoP5xUX4rNULLQPIiHk41KCD8XpM,26355
14
14
  Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZxC4,56
15
- Dshell/_DshellParser/ast_nodes.py,sha256=uKSbK32Ez2wRX9lnH4DA-Ne3yq2v73YJ-_6ObA8U14k,17749
16
- Dshell/_DshellParser/dshell_parser.py,sha256=hWatNRY6E3F6u-Y71dM45wnIeMLoInJh1vlXAD44rJ0,16969
15
+ Dshell/_DshellParser/ast_nodes.py,sha256=CXUG0rIJNh4jzMCgCcRqmQwU0WQoESQ-5FkuVtZZndM,17717
16
+ Dshell/_DshellParser/dshell_parser.py,sha256=73eKwY7iBzBtL6n2IxJcvtSz0xkfE5y1qEffZ2YfXXY,16913
17
17
  Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8qrJWw_s,172
18
18
  Dshell/_DshellTokenizer/dshell_keywords.py,sha256=HtrOQiND_TdM2pdNNAdjBZK2Lhzm2_9umY2dmKfFMTQ,5675
19
19
  Dshell/_DshellTokenizer/dshell_token_type.py,sha256=gYIb2XN2YcgeRgmar_rBDS5CGmwfmxihu8mOW_d6lbE,1533
20
20
  Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=LZGs4Ytuyx9Galazqtz32lS4Mmu9yZya1B7AzFQAQOk,7150
21
- dshellinterpreter-0.2.13.3.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
22
- dshellinterpreter-0.2.13.3.dist-info/METADATA,sha256=xqvU62szhgive2IfV7RtSsL8c051YxMd1m6D6ynp6_I,1151
23
- dshellinterpreter-0.2.13.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
- dshellinterpreter-0.2.13.3.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
25
- dshellinterpreter-0.2.13.3.dist-info/RECORD,,
21
+ dshellinterpreter-0.2.13.5.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
22
+ dshellinterpreter-0.2.13.5.dist-info/METADATA,sha256=5U40G2EGuFk9mnKAQ9Cd4bfT-MyP2JvX2UEu_g4cSsQ,1151
23
+ dshellinterpreter-0.2.13.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
+ dshellinterpreter-0.2.13.5.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
25
+ dshellinterpreter-0.2.13.5.dist-info/RECORD,,