dshellInterpreter 0.2.16.1__tar.gz → 0.2.17.0__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 (35) hide show
  1. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/DISCORD_COMMANDS/utils/utils_global.py +2 -2
  2. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/DISCORD_COMMANDS/utils/utils_member.py +6 -3
  3. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/DISCORD_COMMANDS/utils/utils_permissions.py +1 -1
  4. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/_DshellInterpreteur/dshell_interpreter.py +12 -2
  5. {dshellinterpreter-0.2.16.1/dshellInterpreter.egg-info → dshellinterpreter-0.2.17.0}/PKG-INFO +1 -1
  6. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0/dshellInterpreter.egg-info}/PKG-INFO +1 -1
  7. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/setup.py +1 -1
  8. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/DISCORD_COMMANDS/__init__.py +0 -0
  9. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/DISCORD_COMMANDS/dshell_channel.py +0 -0
  10. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/DISCORD_COMMANDS/dshell_interaction.py +0 -0
  11. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/DISCORD_COMMANDS/dshell_member.py +0 -0
  12. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/DISCORD_COMMANDS/dshell_message.py +0 -0
  13. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/DISCORD_COMMANDS/dshell_pastbin.py +0 -0
  14. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/DISCORD_COMMANDS/dshell_role.py +0 -0
  15. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/DISCORD_COMMANDS/utils/__init__.py +0 -0
  16. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/DISCORD_COMMANDS/utils/utils_list.py +0 -0
  17. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/DISCORD_COMMANDS/utils/utils_message.py +0 -0
  18. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/DISCORD_COMMANDS/utils/utils_thread.py +0 -0
  19. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/_DshellInterpreteur/__init__.py +0 -0
  20. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/_DshellParser/__init__.py +0 -0
  21. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/_DshellParser/ast_nodes.py +0 -0
  22. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/_DshellParser/dshell_parser.py +0 -0
  23. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/_DshellTokenizer/__init__.py +0 -0
  24. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/_DshellTokenizer/dshell_keywords.py +0 -0
  25. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/_DshellTokenizer/dshell_token_type.py +0 -0
  26. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/_DshellTokenizer/dshell_tokenizer.py +0 -0
  27. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/__init__.py +0 -0
  28. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/Dshell/_utils.py +0 -0
  29. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/LICENSE +0 -0
  30. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/README.md +0 -0
  31. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/dshellInterpreter.egg-info/SOURCES.txt +0 -0
  32. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/dshellInterpreter.egg-info/dependency_links.txt +0 -0
  33. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/dshellInterpreter.egg-info/requires.txt +0 -0
  34. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/dshellInterpreter.egg-info/top_level.txt +0 -0
  35. {dshellinterpreter-0.2.16.1 → dshellinterpreter-0.2.17.0}/setup.cfg +0 -0
@@ -127,7 +127,7 @@ async def utils_get_roles(ctx: Message, value: int):
127
127
 
128
128
  guild = ctx.guild
129
129
 
130
- what_is = utils_what_discord_type_is(ctx, value)
130
+ what_is, member = utils_what_discord_type_is(ctx, value)
131
131
 
132
132
  if what_is == DiscordType.UNKNOWN:
133
133
  raise ValueError(f"{value} member not found in guild {guild.name}")
@@ -136,4 +136,4 @@ async def utils_get_roles(ctx: Message, value: int):
136
136
  raise TypeError(f"value must be a member id in roles command, not {what_is}")
137
137
 
138
138
  from ..._DshellParser.ast_nodes import ListNode
139
- return ListNode([i.id for i in guild.get_member(value).roles])
139
+ return ListNode([i.id for i in member.roles])
@@ -5,7 +5,7 @@ from discord import Message, PermissionOverwrite
5
5
 
6
6
  from .utils_global import utils_what_discord_type_is, DiscordType
7
7
 
8
- async def utils_has_permissions(ctx: Message, member: int, permission: PermissionOverwrite) -> bool:
8
+ async def utils_has_permissions(ctx: Message, member: int, permission: dict[None, PermissionOverwrite]) -> bool:
9
9
  """
10
10
  Return True if the member has the specified permissions.
11
11
  :param member:
@@ -16,12 +16,15 @@ async def utils_has_permissions(ctx: Message, member: int, permission: Permissio
16
16
  if not isinstance(member, int):
17
17
  raise TypeError(f"member must be an int in has_perms command, not {type(member)}")
18
18
 
19
- if not isinstance(permission, PermissionOverwrite):
19
+ if not isinstance(permission, dict):
20
20
  raise TypeError(f"permissions must be a permission bloc in has_perms command, not {type(permission)}")
21
21
 
22
+ if None not in permission:
23
+ raise ValueError(f"permissions must have simple 'allow' permission in has_perms command, not {permission.keys()}")
24
+
22
25
  discord_type, member = utils_what_discord_type_is(ctx, member)
23
26
 
24
27
  if discord_type != DiscordType.MEMBER:
25
28
  raise ValueError(f"No member found with ID {member} in has_perms command.")
26
29
 
27
- return (member.guild_permissions & permission.pair()[0]) == permission.pair()[0]
30
+ return (member.guild_permissions & permission[None].pair()[0]) == permission[None].pair()[0]
@@ -39,7 +39,7 @@ class DshellPermissions:
39
39
  return instance
40
40
  raise ValueError(f"No role found with ID {role_id} in perm command.")
41
41
 
42
- def get_permission_overwrite(self, guild: Guild) -> dict[Union[Member, Role], PermissionOverwrite]:
42
+ def get_permission_overwrite(self, guild: Guild) -> dict[Union[Member, Role, None], PermissionOverwrite]:
43
43
  """
44
44
  Returns a PermissionOverwrite object with member and role permissions.
45
45
  If no members or roles are specified, it returns a PermissionOverwrite with None key.
@@ -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, debug: bool = False, vars: Optional[str] = None):
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.2.16.1
3
+ Version: 0.2.17.0
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.16.1
3
+ Version: 0.2.17.0
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.16.1",
8
+ version="0.2.17.0",
9
9
  author="Chronos",
10
10
  author_email="vagabonwalybi@gmail.com",
11
11
  description="A Discord bot interpreter for creating custom commands and automations.",