dshellInterpreter 0.2.17.1__tar.gz → 0.2.17.2__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 (36) hide show
  1. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/DISCORD_COMMANDS/utils/utils_global.py +17 -1
  2. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/_DshellInterpreteur/__init__.py +1 -0
  3. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/_DshellInterpreteur/dshell_interpreter.py +5 -1
  4. dshellinterpreter-0.2.17.2/Dshell/_DshellInterpreteur/errors.py +8 -0
  5. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/_DshellParser/ast_nodes.py +5 -4
  6. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/_DshellParser/dshell_parser.py +7 -1
  7. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/_DshellTokenizer/dshell_keywords.py +3 -0
  8. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/__init__.py +1 -0
  9. {dshellinterpreter-0.2.17.1/dshellInterpreter.egg-info → dshellinterpreter-0.2.17.2}/PKG-INFO +1 -1
  10. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2/dshellInterpreter.egg-info}/PKG-INFO +1 -1
  11. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/dshellInterpreter.egg-info/SOURCES.txt +1 -0
  12. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/setup.py +1 -1
  13. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/DISCORD_COMMANDS/__init__.py +0 -0
  14. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/DISCORD_COMMANDS/dshell_channel.py +0 -0
  15. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/DISCORD_COMMANDS/dshell_interaction.py +0 -0
  16. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/DISCORD_COMMANDS/dshell_member.py +0 -0
  17. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/DISCORD_COMMANDS/dshell_message.py +0 -0
  18. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/DISCORD_COMMANDS/dshell_pastbin.py +0 -0
  19. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/DISCORD_COMMANDS/dshell_role.py +0 -0
  20. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/DISCORD_COMMANDS/utils/__init__.py +0 -0
  21. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/DISCORD_COMMANDS/utils/utils_list.py +0 -0
  22. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/DISCORD_COMMANDS/utils/utils_member.py +0 -0
  23. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/DISCORD_COMMANDS/utils/utils_message.py +0 -0
  24. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/DISCORD_COMMANDS/utils/utils_permissions.py +0 -0
  25. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/DISCORD_COMMANDS/utils/utils_thread.py +0 -0
  26. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/_DshellParser/__init__.py +0 -0
  27. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/_DshellTokenizer/__init__.py +0 -0
  28. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/_DshellTokenizer/dshell_token_type.py +0 -0
  29. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/_DshellTokenizer/dshell_tokenizer.py +0 -0
  30. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/Dshell/_utils.py +0 -0
  31. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/LICENSE +0 -0
  32. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/README.md +0 -0
  33. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/dshellInterpreter.egg-info/dependency_links.txt +0 -0
  34. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/dshellInterpreter.egg-info/requires.txt +0 -0
  35. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/dshellInterpreter.egg-info/top_level.txt +0 -0
  36. {dshellinterpreter-0.2.17.1 → dshellinterpreter-0.2.17.2}/setup.cfg +0 -0
@@ -1,5 +1,6 @@
1
1
  __all__ = [
2
2
  "utils_len",
3
+ "utils_random",
3
4
  "utils_get_name",
4
5
  "utils_get_id",
5
6
  "utils_get_roles",
@@ -7,8 +8,9 @@ __all__ = [
7
8
 
8
9
  from discord import Message, Role, TextChannel, VoiceChannel, CategoryChannel, ForumChannel, Thread, Member, Guild
9
10
  from discord.utils import get
10
- from typing import Union
11
+ from typing import Union, Optional
11
12
  from enum import StrEnum
13
+ from random import random, choice
12
14
 
13
15
 
14
16
  class DiscordType(StrEnum):
@@ -65,6 +67,20 @@ async def utils_len(ctx: Message, value):
65
67
 
66
68
  return len(value)
67
69
 
70
+ async def utils_random(ctx: Message, value: Optional["ListNode"] = None):
71
+ """
72
+ Return a random element from a list, or a random integer between 0 and value
73
+ :param value:
74
+ :return:
75
+ """
76
+ from ..._DshellParser.ast_nodes import ListNode
77
+ if value is not None and not isinstance(value, ListNode):
78
+ raise TypeError(f"value must be a list in random command, not {type(value)}")
79
+
80
+ if value is None:
81
+ return random()
82
+ return choice(value)
83
+
68
84
  async def utils_get_name(ctx : Message, value: int) -> Union[str, None]:
69
85
  """
70
86
  Return the name of a role, member, or channel.
@@ -1 +1,2 @@
1
1
  from .dshell_interpreter import *
2
+ from .errors import *
@@ -9,6 +9,7 @@ from discord import AutoShardedBot, Embed, Colour, PermissionOverwrite, Permissi
9
9
  from discord.ui import Button
10
10
  from discord.abc import PrivateChannel
11
11
 
12
+ from .errors import *
12
13
  from .._DshellParser.ast_nodes import *
13
14
  from ..DISCORD_COMMANDS.utils.utils_permissions import DshellPermissions
14
15
  from .._DshellParser.dshell_parser import parse
@@ -194,7 +195,10 @@ class DshellInterpreteur:
194
195
 
195
196
 
196
197
  elif isinstance(node, EndNode):
197
- raise RuntimeError("Execution stopped - EndNode encountered")
198
+ if node.error_message:
199
+ raise RuntimeError("Execution stopped - EndNode encountered")
200
+ else:
201
+ raise DshellInterpreterStopExecution()
198
202
 
199
203
  def eval_data_token(self, token: Token):
200
204
  """
@@ -0,0 +1,8 @@
1
+
2
+ class DshellInterpreterError(Exception):
3
+ """Base class for exceptions in this module."""
4
+ pass
5
+
6
+ class DshellInterpreterStopExecution(DshellInterpreterError):
7
+ """Exception raised to stop the execution of the interpreter."""
8
+ pass
@@ -1,5 +1,5 @@
1
1
  from random import randint
2
- from typing import Optional, Any
2
+ from typing import Optional, Any, Union
3
3
 
4
4
  from .._DshellTokenizer.dshell_token_type import Token
5
5
 
@@ -286,8 +286,8 @@ class EndNode(ASTNode):
286
286
  Node representing the end of the AST.
287
287
  """
288
288
 
289
- def __init__(self):
290
- pass
289
+ def __init__(self, error_message: Union[Token, bool] = True):
290
+ self.error_message: bool = error_message
291
291
 
292
292
  def __repr__(self):
293
293
  return f"<END>"
@@ -298,7 +298,8 @@ class EndNode(ASTNode):
298
298
  :return: Dictionary representation of the EndNode.
299
299
  """
300
300
  return {
301
- "type": "EndNode"
301
+ "type": "EndNode",
302
+ "error_message": self.error_message
302
303
  }
303
304
 
304
305
 
@@ -158,7 +158,13 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
158
158
  return blocks, pointeur # on renvoie les informations parsé à la dernière paramètre ouverte
159
159
 
160
160
  elif first_token_line.value == '#end': # node pour arrêter le programme si elle est rencontré
161
- end_node = EndNode()
161
+ error_message = True
162
+ if len(tokens_by_line) > 1:
163
+ if tokens_by_line[1].type != DTT.BOOL:
164
+ raise TypeError(f'[#END] the variable given must be a boolean, not {tokens_by_line[1].type}')
165
+ else:
166
+ error_message = tokens_by_line[1]
167
+ end_node = EndNode(error_message)
162
168
  last_block.body.append(end_node)
163
169
 
164
170
  ############################## DISCORD KEYWORDS ##############################
@@ -29,6 +29,9 @@ dshell_discord_keyword: set[str] = {
29
29
  }
30
30
  dshell_commands: dict[str, Callable] = {
31
31
 
32
+ ## global utils
33
+ 'random': utils_random,
34
+
32
35
  ## List utils
33
36
  'length': utils_len,
34
37
  'len': utils_len,
@@ -1,2 +1,3 @@
1
1
  from ._DshellInterpreteur.dshell_interpreter import DshellInterpreteur
2
+ from ._DshellInterpreteur.errors import *
2
3
  from ._utils import *
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.2.17.1
3
+ Version: 0.2.17.2
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.17.1
3
+ Version: 0.2.17.2
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
@@ -19,6 +19,7 @@ Dshell/DISCORD_COMMANDS/utils/utils_permissions.py
19
19
  Dshell/DISCORD_COMMANDS/utils/utils_thread.py
20
20
  Dshell/_DshellInterpreteur/__init__.py
21
21
  Dshell/_DshellInterpreteur/dshell_interpreter.py
22
+ Dshell/_DshellInterpreteur/errors.py
22
23
  Dshell/_DshellParser/__init__.py
23
24
  Dshell/_DshellParser/ast_nodes.py
24
25
  Dshell/_DshellParser/dshell_parser.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setup(
7
7
  name="dshellInterpreter",
8
- version="0.2.17.1",
8
+ version="0.2.17.2",
9
9
  author="Chronos",
10
10
  author_email="vagabonwalybi@gmail.com",
11
11
  description="A Discord bot interpreter for creating custom commands and automations.",