dshellInterpreter 1.2.0.21__tar.gz → 1.2.1.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.
Files changed (53) hide show
  1. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/dshell_channel.py +24 -17
  2. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellInterpreteur/dshell_interpreter.py +11 -2
  3. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellParser/ast_nodes.py +0 -21
  4. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellParser/dshell_parser.py +2 -6
  5. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellTokenizer/dshell_keywords.py +2 -1
  6. {dshellinterpreter-1.2.0.21/dshellInterpreter.egg-info → dshellinterpreter-1.2.1.0}/PKG-INFO +1 -1
  7. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0/dshellInterpreter.egg-info}/PKG-INFO +1 -1
  8. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/setup.py +1 -1
  9. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/__init__.py +0 -0
  10. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/dshell_embed.py +0 -0
  11. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/dshell_file.py +0 -0
  12. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/dshell_interaction.py +0 -0
  13. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/dshell_member.py +0 -0
  14. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/dshell_message.py +0 -0
  15. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/dshell_pastbin.py +0 -0
  16. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/dshell_role.py +0 -0
  17. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/dshell_ui.py +0 -0
  18. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/utils/__init__.py +0 -0
  19. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/utils/utils_embed.py +0 -0
  20. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/utils/utils_file.py +0 -0
  21. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/utils/utils_global.py +0 -0
  22. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/utils/utils_list.py +0 -0
  23. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/utils/utils_member.py +0 -0
  24. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/utils/utils_message.py +0 -0
  25. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/utils/utils_numbers.py +0 -0
  26. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/utils/utils_permissions.py +0 -0
  27. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/utils/utils_string.py +0 -0
  28. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/utils/utils_thread.py +0 -0
  29. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DISCORD_COMMANDS/utils/utils_type_validation.py +0 -0
  30. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellInterpreteur/__init__.py +0 -0
  31. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellInterpreteur/cached_messages.py +0 -0
  32. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellInterpreteur/dshell_arguments.py +0 -0
  33. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellInterpreteur/dshell_global_variables.py +0 -0
  34. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellInterpreteur/dshell_scope.py +0 -0
  35. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellInterpreteur/errors.py +0 -0
  36. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellInterpreteur/utils_interpreter.py +0 -0
  37. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellParser/__init__.py +0 -0
  38. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellParser/errors.py +0 -0
  39. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellPreProcess/__init__.py +0 -0
  40. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellPreProcess/dshell_preprocess.py +0 -0
  41. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellTokenizer/__init__.py +0 -0
  42. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellTokenizer/dshell_token_type.py +0 -0
  43. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/DshellTokenizer/dshell_tokenizer.py +0 -0
  44. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/__init__.py +0 -0
  45. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/full_import.py +0 -0
  46. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/Dshell/regex_test.py +0 -0
  47. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/LICENSE +0 -0
  48. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/README.md +0 -0
  49. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/dshellInterpreter.egg-info/SOURCES.txt +0 -0
  50. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/dshellInterpreter.egg-info/dependency_links.txt +0 -0
  51. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/dshellInterpreter.egg-info/requires.txt +0 -0
  52. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/dshellInterpreter.egg-info/top_level.txt +0 -0
  53. {dshellinterpreter-1.2.0.21 → dshellinterpreter-1.2.1.0}/setup.cfg +0 -0
@@ -75,12 +75,15 @@ async def dshell_get_channels(ctx: Message, name: Optional[StrNode]=None, regex:
75
75
  channels = ListNode([])
76
76
 
77
77
  for channel in ctx.channel.guild.channels:
78
- if name is not None and channel.name == StrNode(name):
78
+ if name is not None and channel.name == name:
79
79
  channels.add(IntNode(channel.id))
80
80
 
81
81
  elif regex is not None and search(regex, channel.name):
82
82
  channels.add(IntNode(channel.id))
83
83
 
84
+ else:
85
+ channels.add(IntNode(channel.id))
86
+
84
87
  return channels
85
88
 
86
89
  async def dshell_get_channels_in_category(ctx: Message,
@@ -155,13 +158,15 @@ async def dshell_create_text_channel(ctx: Message,
155
158
 
156
159
  channel_category = ctx.channel.category if category is None else ctx.channel.guild.get_channel(category)
157
160
 
161
+ final_permissions = permissions.value if not isinstance(permissions, _MissingSentinel) else permissions
162
+
158
163
  created_channel = await ctx.guild.create_text_channel(str(name),
159
164
  category=channel_category,
160
165
  position=position,
161
166
  slowmode_delay=slowmode,
162
167
  topic=topic,
163
168
  nsfw=nsfw,
164
- overwrites=permissions.value,
169
+ overwrites=final_permissions,
165
170
  reason=reason)
166
171
 
167
172
  return IntNode(created_channel.id)
@@ -193,19 +198,21 @@ async def dshell_create_voice_channel(ctx: Message,
193
198
 
194
199
  channel_category = ctx.channel.category if category is None else ctx.channel.guild.get_channel(category)
195
200
 
201
+ final_permissions = permissions.value if not isinstance(permissions, _MissingSentinel) else permissions
202
+
196
203
  created_channel = await ctx.guild.create_voice_channel(StrNode(name),
197
204
  category=channel_category,
198
205
  position=position,
199
206
  bitrate=bitrate,
200
- overwrites=permissions.value,
207
+ overwrites=final_permissions,
201
208
  reason=reason)
202
209
 
203
210
  return IntNode(created_channel.id)
204
211
 
205
212
 
206
213
  async def dshell_delete_channel(ctx: Message,
207
- channel=None,
208
- reason=None,
214
+ channel: Optional[IntNode]=None,
215
+ reason: Optional[StrNode]=None,
209
216
  timeout: FloatNode = FloatNode(0)):
210
217
  """
211
218
  Deletes a channel.
@@ -285,7 +292,7 @@ async def dshell_edit_text_channel(ctx: Message,
285
292
  _validate_optional_string(reason, "Reason", _CMD)
286
293
 
287
294
  channel_to_edit = ctx.channel if channel is None else ctx.channel.guild.get_channel(channel)
288
- new_categoy = ctx.channel.category if isinstance(category, _MissingSentinel) else ctx.channel.guild.get_channel(category)
295
+ new_categoy = ctx.channel.category if category is MISSING else ctx.channel.guild.get_channel(category)
289
296
 
290
297
  if channel_to_edit is None:
291
298
  raise Exception(f"Channel {channel} not found !")
@@ -303,13 +310,13 @@ async def dshell_edit_text_channel(ctx: Message,
303
310
 
304
311
 
305
312
  async def dshell_edit_voice_channel(ctx: Message,
306
- channel=None,
313
+ channel: Optional[IntNode]=None,
307
314
  name: Optional[StrNode]=None,
308
315
  category: IntNode = MISSING,
309
316
  position: IntNode = MISSING,
310
317
  bitrate: IntNode = MISSING,
311
318
  permissions: PermissionNode = MISSING,
312
- reason=None):
319
+ reason: Optional[StrNode]=None):
313
320
  """
314
321
  Edits a voice channel on the server
315
322
  """
@@ -330,7 +337,7 @@ async def dshell_edit_voice_channel(ctx: Message,
330
337
  _validate_optional_string(reason, "Reason", _CMD)
331
338
 
332
339
  channel_to_edit = ctx.channel if channel is None else ctx.channel.guild.get_channel(channel)
333
- new_categoy = ctx.channel.category if isinstance(category, _MissingSentinel) else ctx.channel.guild.get_channel(category)
340
+ new_categoy = ctx.channel.category if category is MISSING else ctx.channel.guild.get_channel(category)
334
341
 
335
342
  if channel_to_edit is None:
336
343
  raise Exception(f"Channel {channel} not found !")
@@ -356,7 +363,7 @@ async def dshell_create_thread_message(ctx: Message,
356
363
 
357
364
  _CMD = "ct"
358
365
 
359
- message = ctx if message is None else await utils_get_message(ctx, message)
366
+ final_message = ctx if message is None else await utils_get_message(ctx, message)
360
367
 
361
368
  _validate_required_string(name, "Name", _CMD)
362
369
 
@@ -372,7 +379,7 @@ async def dshell_create_thread_message(ctx: Message,
372
379
  if isinstance(slowmode, IntNode) and slowmode < 0:
373
380
  raise Exception("Slowmode delay must be a positive integer !")
374
381
 
375
- thread = await message.create_thread(name=name,
382
+ thread = await final_message.create_thread(name=name,
376
383
  auto_archive_duration=archive,
377
384
  slowmode_delay=slowmode)
378
385
 
@@ -394,7 +401,7 @@ async def dshell_edit_thread(ctx: Message,
394
401
  if thread is None:
395
402
  raise Exception("Thread must be specified !")
396
403
 
397
- thread = await utils_get_thread(ctx, thread)
404
+ final_thread = await utils_get_thread(ctx, thread)
398
405
 
399
406
  _validate_missing_or_type(name, "Name", StrNode, _CMD)
400
407
 
@@ -410,12 +417,12 @@ async def dshell_edit_thread(ctx: Message,
410
417
  if isinstance(slowmode, IntNode) and slowmode < 0:
411
418
  raise Exception("Slowmode delay must be a positive integer !")
412
419
 
413
- await thread.edit(name=name if name is not None else thread.name,
420
+ await final_thread.edit(name=name if name is not None else thread.name,
414
421
  auto_archive_duration=archive if archive is not MISSING else thread.auto_archive_duration,
415
422
  slowmode_delay=slowmode if slowmode is not MISSING else thread.slowmode_delay,
416
423
  reason=reason)
417
424
 
418
- return IntNode(thread.id)
425
+ return IntNode(final_thread.id)
419
426
 
420
427
 
421
428
  async def dshell_get_thread(ctx: Message, message: Optional[Union[IntNode, StrNode]] = None):
@@ -425,13 +432,13 @@ async def dshell_get_thread(ctx: Message, message: Optional[Union[IntNode, StrNo
425
432
 
426
433
  _CMD = "gt"
427
434
 
428
- message = ctx if message is None else await utils_get_message(ctx, message)
435
+ final_message = ctx if message is None else await utils_get_message(ctx, message)
429
436
 
430
437
  # Return None if message doesn't have thread attribute (not raising error for this case)
431
438
  if not hasattr(message, 'thread'):
432
439
  return None
433
440
 
434
- thread = message.thread
441
+ thread = final_message.thread
435
442
 
436
443
  if thread is None:
437
444
  return None
@@ -486,7 +493,7 @@ async def dshell_create_category(ctx: Message,
486
493
  return IntNode(created_category.id)
487
494
 
488
495
  async def dshell_edit_category(ctx: Message,
489
- category,
496
+ category: IntNode,
490
497
  name: Optional[StrNode]=None,
491
498
  position=MISSING,
492
499
  permissions: PermissionNode = MISSING,
@@ -1,6 +1,6 @@
1
1
  from ..DshellTokenizer.dshell_token_type import Token
2
2
  from ..DshellTokenizer.dshell_token_type import DshellTokenType as DTT
3
- from ..DshellInterpreteur.errors import DshellInterpreterStopExecution
3
+ from ..DshellInterpreteur.errors import DshellInterpreterStopExecution, DshellInterpreterError
4
4
  from Dshell.full_import import TypeVar, Union, Optional, Any, Callable, sleep, findall
5
5
  from ..DshellParser.ast_nodes import *
6
6
  from Dshell.full_import import AutoShardedBot, Interaction, Message, PrivateChannel
@@ -120,6 +120,7 @@ class DshellInterpreteur:
120
120
  print_ast(self.ast)
121
121
 
122
122
  self.raise_error = False
123
+ self.end_program: bool = False
123
124
 
124
125
  async def _execute_command_node(self, node: CommandNode):
125
126
  """Execute a command node."""
@@ -155,6 +156,9 @@ class DshellInterpreteur:
155
156
  self.env.set('__break__', BoolNode(0))
156
157
  break
157
158
 
159
+ if self.end_program:
160
+ break
161
+
158
162
  async def _execute_break_node(self, node: BreakNode):
159
163
  """Execute a break node."""
160
164
  self.env.set('__break__', BoolNode(1))
@@ -223,9 +227,14 @@ class DshellInterpreteur:
223
227
 
224
228
  for node in ast:
225
229
 
230
+ # cut the current program if an EndNode is encountred with the parameter "error_message" to False
231
+ if self.end_program:
232
+ return
233
+
226
234
  try:
227
235
  if isinstance(node, StartNode):
228
236
  await self.execute(node.body)
237
+ return
229
238
 
230
239
  if isinstance(node, CommandNode):
231
240
  await self._execute_command_node(node)
@@ -260,7 +269,7 @@ class DshellInterpreteur:
260
269
  if await self.eval_data_token(node.error_message):
261
270
  raise RuntimeError("Execution stopped - EndNode encountered")
262
271
  else:
263
- raise DshellInterpreterStopExecution("Execution stopped without error")
272
+ self.end_program = True
264
273
 
265
274
  except Exception as e:
266
275
  if not self.raise_error:
@@ -35,7 +35,6 @@ __all__ = [
35
35
  'UiButtonNode',
36
36
  'UiSelectNode',
37
37
  'OptionUiSelectNode',
38
- 'ScanNode',
39
38
  'FileNode',
40
39
  'FileStreamNode'
41
40
  ]
@@ -337,26 +336,6 @@ class ArgsCommandNode(ASTNode):
337
336
  "body": [token.to_dict() for token in self.body]
338
337
  }
339
338
 
340
- class ScanNode(ASTNode):
341
- """
342
- Node representing a scan message in the AST
343
- """
344
- def __init__(self, body: ArgsCommandNode, line: int):
345
- super().__init__(line)
346
- self.body = body
347
-
348
- def __repr__(self):
349
- return StrNode(f"<SCAN> - {self.body}")
350
-
351
- def to_dict(self):
352
- """
353
- Convert the ScanNode to a dictionary representation.
354
- :return: Dictionary representation of the ScanNode.
355
- """
356
- return {
357
- "type": "ScanNode",
358
- "body": self.body.to_dict()
359
- }
360
339
 
361
340
  class CommandNode(ASTNode):
362
341
  """
@@ -221,18 +221,14 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
221
221
  return_node = ReturnNode(body=tokens_by_line[1:], line=line)
222
222
  last_block.body.append(return_node)
223
223
 
224
- elif first_token_line.value == 'scan':
225
- scan_node = ScanNode(ArgsCommandNode(body=tokens_by_line[1:], line=line), line=line)
226
- last_block.body.append(scan_node)
227
-
228
224
  elif first_token_line.value == '#end': # node pour arrêter le programme si elle est rencontré
229
- error_message = True
225
+ error_message = BoolNode(1)
230
226
  if len_tokens_by_line_since_command_name > 0:
231
227
  if tokens_by_line[1].type != DTT.BOOL:
232
228
  raise TypeError(f'[#END] the variable given must be a boolean, not {tokens_by_line[1].type}')
233
229
  else:
234
230
  error_message = tokens_by_line[1]
235
- end_node = EndNode(error_message)
231
+ end_node = EndNode(line=line, error_message=error_message)
236
232
  last_block.body.append(end_node)
237
233
 
238
234
  ############################## DISCORD KEYWORDS ##############################
@@ -11,7 +11,6 @@ __all__ = [
11
11
  from ..DISCORD_COMMANDS import *
12
12
 
13
13
  from Dshell.full_import import Callable
14
- from ..DISCORD_COMMANDS.dshell_file import dshell_read_file, dshell_write_file, dshell_get_message_files
15
14
 
16
15
  dshell_keyword: set[str] = {
17
16
  'if', 'else', 'elif', 'loop', '#end', 'var', '#loop', '#if', 'sleep', 'param', '#param', 'code', '#code', 'eval', 'return', 'break'
@@ -184,6 +183,8 @@ dshell_mathematical_operators: dict[str, tuple[Callable, int, int, int]] = {
184
183
  r"%": (lambda a, b: a % b, 7, 2, 2),
185
184
  r"-": (lambda a, b=None: a-b if b is not None else -a, 6, 1, 2),
186
185
  r"+": (lambda a, b: a + b, 6, 2, 2),
186
+ r"..": (lambda a, b: ListNode([IntNode(i) for i in range(IntNode(a), IntNode(b))])
187
+ if a <= b else ListNode([IntNode(i) for i in range(IntNode(a), IntNode(b), -1)]), 5, 2, 2)
187
188
  # warning: ambiguity between unary and binary to be handled in your parser
188
189
 
189
190
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 1.2.0.21
3
+ Version: 1.2.1.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: 1.2.0.21
3
+ Version: 1.2.1.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="1.2.0.21",
8
+ version="1.2.1.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.",