dshellInterpreter 0.2.18.4__tar.gz → 0.2.18.5__tar.gz

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.

Files changed (37) hide show
  1. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/_DshellInterpreteur/dshell_interpreter.py +10 -23
  2. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/_DshellParser/ast_nodes.py +25 -1
  3. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/_DshellParser/dshell_parser.py +2 -0
  4. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/_DshellTokenizer/dshell_token_type.py +1 -1
  5. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/_DshellTokenizer/dshell_tokenizer.py +2 -1
  6. {dshellinterpreter-0.2.18.4/dshellInterpreter.egg-info → dshellinterpreter-0.2.18.5}/PKG-INFO +1 -1
  7. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5/dshellInterpreter.egg-info}/PKG-INFO +1 -1
  8. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/setup.py +1 -1
  9. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/__init__.py +0 -0
  10. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/dshell_channel.py +0 -0
  11. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/dshell_interaction.py +0 -0
  12. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/dshell_member.py +0 -0
  13. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/dshell_message.py +0 -0
  14. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/dshell_pastbin.py +0 -0
  15. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/dshell_role.py +0 -0
  16. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/utils/__init__.py +0 -0
  17. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/utils/utils_global.py +0 -0
  18. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/utils/utils_list.py +0 -0
  19. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/utils/utils_member.py +0 -0
  20. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/utils/utils_message.py +0 -0
  21. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/utils/utils_permissions.py +0 -0
  22. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/utils/utils_string.py +0 -0
  23. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/DISCORD_COMMANDS/utils/utils_thread.py +0 -0
  24. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/_DshellInterpreteur/__init__.py +0 -0
  25. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/_DshellInterpreteur/errors.py +0 -0
  26. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/_DshellParser/__init__.py +0 -0
  27. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/_DshellTokenizer/__init__.py +0 -0
  28. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/_DshellTokenizer/dshell_keywords.py +0 -0
  29. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/__init__.py +0 -0
  30. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/Dshell/_utils.py +0 -0
  31. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/LICENSE +0 -0
  32. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/README.md +0 -0
  33. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/dshellInterpreter.egg-info/SOURCES.txt +0 -0
  34. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/dshellInterpreter.egg-info/dependency_links.txt +0 -0
  35. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/dshellInterpreter.egg-info/requires.txt +0 -0
  36. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/dshellInterpreter.egg-info/top_level.txt +0 -0
  37. {dshellinterpreter-0.2.18.4 → dshellinterpreter-0.2.18.5}/setup.cfg +0 -0
@@ -57,10 +57,10 @@ class DshellInterpreteur:
57
57
  '__author_id__': message.author.id,
58
58
 
59
59
  '__message__': message.content,
60
- '__message_author__': message.author.id,
61
- '__message_before__': message.content, # same as __message__, but before edit. Can be overwritten by add vars_env parameter
62
60
  '__message_content__': message.content,
63
61
  '__message_id__': message.id,
62
+ '__message_author__': message.author.id,
63
+ '__message_before__': message.content, # same as __message__, but before edit. Can be overwritten by add vars_env parameter
64
64
  '__message_url__': message.jump_url if hasattr(message, 'jump_url') else None,
65
65
  '__last_message__': message.channel.last_message_id,
66
66
 
@@ -90,7 +90,7 @@ class DshellInterpreteur:
90
90
  '__guild_forum_channels__': ListNode([channel.id for channel in message.channel.guild.forum_channels]),
91
91
  '__guild_channels_count__': len(message.channel.guild.channels),
92
92
 
93
- } if message is not None and not debug else {} # {} is used in debug mode, when ctx is None
93
+ } if message is not None and not debug else {'__ret__': None}
94
94
  if vars_env is not None: # add the variables to the environment
95
95
  self.env.update(vars_env)
96
96
  self.vars = vars if vars is not None else ''
@@ -179,9 +179,6 @@ class DshellInterpreteur:
179
179
  else:
180
180
  self.env[node.name.value] = build_ui(first_node, self)
181
181
 
182
- elif isinstance(first_node, LengthNode):
183
- self.env[node.name.value] = length(first_node)
184
-
185
182
  else:
186
183
  self.env[node.name.value] = eval_expression(node.body, self)
187
184
 
@@ -225,8 +222,9 @@ class DshellInterpreteur:
225
222
  if token.value in self.env.keys():
226
223
  return self.env[token.value]
227
224
  return token.value
228
- elif token.type == DTT.CALL_ARGS:
229
- return (self.eval_data_token(tok) for tok in token.value)
225
+ elif token.type == DTT.EVAL_GROUP:
226
+ self.execute(token.value)
227
+ return self.env['__ret__']
230
228
  elif token.type == DTT.STR:
231
229
  for match in findall(rf"\$({'|'.join(self.env.keys())})", token.value):
232
230
  token.value = token.value.replace('$' + match, str(self.env[match]))
@@ -376,8 +374,10 @@ def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur, norma
376
374
  :param interpreter: The Dshell interpreter instance.
377
375
  :param normalise: If True, normalises the arguments (make value lowercase).
378
376
  """
379
- tokens = {'*': [],
380
- '--*': {}} # tokens to return
377
+ # tokens to return
378
+ tokens = {'*': [], # not specied parameters
379
+ '--*': {}, # get all tokens after --* until reach the end. It's evaluated.
380
+ }
381
381
  current_arg = '*' # the argument keys are the types they belong to. '*' is for all arguments not explicitly specified by a separator and an IDENT
382
382
  n = len(body)
383
383
  list_tokens: list[dict] = [tokens]
@@ -422,19 +422,6 @@ def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur, norma
422
422
 
423
423
  return list_tokens
424
424
 
425
- def length(variable : LengthNode) -> int:
426
- """
427
- Count characters or items in string/list
428
- :param variable:
429
- :return:
430
- """
431
- if not isinstance(variable.body, ListNode) and variable.body.type not in (DTT.STR, DTT.IDENT):
432
- raise Exception(f'Length take string, ident or list, not {type(variable.body)} !')
433
-
434
- if isinstance(variable.body, ListNode):
435
- return len(variable.body)
436
- else:
437
- return len(variable.body.value)
438
425
 
439
426
  def build_embed_args(body: list[Token], fields: list[FieldEmbedNode], interpreter: DshellInterpreteur) -> tuple[dict, list[dict]]:
440
427
  """
@@ -20,6 +20,7 @@ __all__ = [
20
20
  'SleepNode',
21
21
  'ListNode',
22
22
  'PermissionNode',
23
+ 'EvalGroupNode',
23
24
  'ParamNode',
24
25
  'UiNode',
25
26
  'UiButtonNode',
@@ -405,6 +406,30 @@ class SleepNode(ASTNode):
405
406
  "body": [token.to_dict() for token in self.body]
406
407
  }
407
408
 
409
+ class EvalGroupNode(ASTNode):
410
+ """
411
+ Node representing a group of evaluations in the AST.
412
+ This is used to group multiple evaluations together.
413
+ """
414
+
415
+ def __init__(self, body: list[Token]):
416
+ """
417
+ :param body: list of tokens representing the body of the evaluation group
418
+ """
419
+ self.body = body
420
+
421
+ def __repr__(self):
422
+ return f"<EVAL GROUP> - {self.body}"
423
+
424
+ def to_dict(self):
425
+ """
426
+ Convert the EvalGroupNode to a dictionary representation.
427
+ :return: Dictionary representation of the EvalGroupNode.
428
+ """
429
+ return {
430
+ "type": "EvalGroupNode",
431
+ "body": [token.to_dict() for token in self.body]
432
+ }
408
433
 
409
434
  class ParamNode(ASTNode):
410
435
  """
@@ -432,7 +457,6 @@ class ParamNode(ASTNode):
432
457
  "body": [token.to_dict() for token in self.body]
433
458
  }
434
459
 
435
-
436
460
  class UiButtonNode(ASTNode):
437
461
  """
438
462
  Node representing a UI button component in the AST.
@@ -262,6 +262,8 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
262
262
  elif first_token_line.type == DTT.STR:
263
263
  last_block.body.append(CommandNode(name='sm', body=ArgsCommandNode([first_token_line])))
264
264
 
265
+ elif first_token_line.type == DTT.EVAL_GROUP:
266
+ parse([first_token_line.value], last_block)
265
267
 
266
268
  else:
267
269
  last_block.body += tokens_by_line
@@ -17,7 +17,6 @@ class DshellTokenType(Enum):
17
17
  BOOL = auto(),
18
18
  NONE = auto(),
19
19
  LIST = auto()
20
- CALL_ARGS = auto()
21
20
  DICT = auto()
22
21
  MENTION = auto()
23
22
  IDENT = auto() # nom de variable, fonction
@@ -30,6 +29,7 @@ class DshellTokenType(Enum):
30
29
  MATHS_OPERATOR = auto() # ==, +, -, *, etc.
31
30
  LOGIC_OPERATOR = auto(),
32
31
  LOGIC_WORD_OPERATOR = auto() # and, or, not
32
+ EVAL_GROUP = auto() # `code`
33
33
  COMMENT = auto() # lignes commençant par ##
34
34
 
35
35
 
@@ -17,6 +17,7 @@ table_regex: dict[DTT, Pattern] = {
17
17
  DTT.ENGLOBE_SEPARATOR: compile(rf"--\*\w+\s*(.*?)\s*(?=--|$)"),
18
18
  DTT.STR: compile(r'"((?:[^\\"]|\\.)*)"', flags=DOTALL),
19
19
  DTT.COMMENT: compile(r"::(.*?)$"),
20
+ DTT.EVAL_GROUP: compile(r"`(.*?)`"),
20
21
  DTT.LIST: compile(r"\[(.*?)\]"),
21
22
  DTT.MENTION: compile(r'<(?:@!?|@&|#)([0-9]+)>'),
22
23
  DTT.SEPARATOR: compile(rf"(--)"),
@@ -80,7 +81,7 @@ class DshellTokenizer:
80
81
 
81
82
  if token_type in (
82
83
  DTT.LIST,
83
- DTT.CALL_ARGS): # si c'est un regroupement de donnée, on tokenize ce qu'il contient
84
+ DTT.EVAL_GROUP): # si c'est un regroupement de donnée, on tokenize ce qu'il contient
84
85
  result = self.tokenizer([token.value])
85
86
  token.value = result[0] if len(
86
87
  result) > 0 else result # gère si la structure de donnée est vide ou non
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.2.18.4
3
+ Version: 0.2.18.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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.2.18.4
3
+ Version: 0.2.18.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
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setup(
7
7
  name="dshellInterpreter",
8
- version="0.2.18.4",
8
+ version="0.2.18.5",
9
9
  author="Chronos",
10
10
  author_email="vagabonwalybi@gmail.com",
11
11
  description="A Discord bot interpreter for creating custom commands and automations.",