dshellInterpreter 0.2.13.13__tar.gz → 0.2.13.14__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 (32) hide show
  1. dshellinterpreter-0.2.13.14/Dshell/DISCORD_COMMANDS/dshell_interaction.py +67 -0
  2. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/DISCORD_COMMANDS/dshell_message.py +7 -3
  3. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/_DshellInterpreteur/dshell_interpreter.py +16 -4
  4. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/_DshellParser/dshell_parser.py +20 -0
  5. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/_DshellTokenizer/dshell_keywords.py +3 -1
  6. {dshellinterpreter-0.2.13.13/dshellInterpreter.egg-info → dshellinterpreter-0.2.13.14}/PKG-INFO +1 -1
  7. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14/dshellInterpreter.egg-info}/PKG-INFO +1 -1
  8. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/setup.py +1 -1
  9. dshellinterpreter-0.2.13.13/Dshell/DISCORD_COMMANDS/dshell_interaction.py +0 -42
  10. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/DISCORD_COMMANDS/__init__.py +0 -0
  11. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/DISCORD_COMMANDS/dshell_channel.py +0 -0
  12. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/DISCORD_COMMANDS/dshell_member.py +0 -0
  13. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/DISCORD_COMMANDS/dshell_pastbin.py +0 -0
  14. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/DISCORD_COMMANDS/dshell_role.py +0 -0
  15. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/DISCORD_COMMANDS/utils/__init__.py +0 -0
  16. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/DISCORD_COMMANDS/utils/utils_message.py +0 -0
  17. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/DISCORD_COMMANDS/utils/utils_thread.py +0 -0
  18. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/_DshellInterpreteur/__init__.py +0 -0
  19. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/_DshellParser/__init__.py +0 -0
  20. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/_DshellParser/ast_nodes.py +0 -0
  21. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/_DshellTokenizer/__init__.py +0 -0
  22. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/_DshellTokenizer/dshell_token_type.py +0 -0
  23. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/_DshellTokenizer/dshell_tokenizer.py +0 -0
  24. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/__init__.py +0 -0
  25. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/Dshell/_utils.py +0 -0
  26. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/LICENSE +0 -0
  27. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/README.md +0 -0
  28. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/dshellInterpreter.egg-info/SOURCES.txt +0 -0
  29. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/dshellInterpreter.egg-info/dependency_links.txt +0 -0
  30. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/dshellInterpreter.egg-info/requires.txt +0 -0
  31. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/dshellInterpreter.egg-info/top_level.txt +0 -0
  32. {dshellinterpreter-0.2.13.13 → dshellinterpreter-0.2.13.14}/setup.cfg +0 -0
@@ -0,0 +1,67 @@
1
+ __all__ = [
2
+ 'dshell_respond_interaction',
3
+ 'dshell_defer_interaction'
4
+ ]
5
+
6
+ from types import NoneType
7
+ from discord import Interaction, Embed
8
+ from pycordViews import EasyModifiedViews
9
+
10
+
11
+ async def dshell_respond_interaction(ctx: Interaction, content: str = None, delete=None, mentions: bool = None, hide: bool = False, embeds=None, view=None) -> int:
12
+ """
13
+ Responds to a message interaction on Discord
14
+ """
15
+
16
+ if not isinstance(ctx, Interaction):
17
+ raise Exception(f'Respond to an interaction must be used in an interaction context, not {type(ctx)} !')
18
+
19
+ if delete is not None and not isinstance(delete, (int, float)):
20
+ raise Exception(f'Delete parameter must be a number (seconds) or None, not {type(delete)} !')
21
+
22
+ if not isinstance(mentions, (NoneType, bool)):
23
+ raise Exception(f'Mention parameter must be a boolean or None, not {type(mentions)} !')
24
+
25
+ if not isinstance(hide, bool):
26
+ raise Exception(f'Hide parameter must be a boolean, not {type(hide)} !')
27
+
28
+ allowed_mentions = mentions if mentions is not None else False
29
+
30
+ from .._DshellParser.ast_nodes import ListNode
31
+
32
+ if not isinstance(embeds, (ListNode, Embed, NoneType)):
33
+ raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
34
+
35
+ if embeds is None:
36
+ embeds = ListNode([])
37
+
38
+ elif isinstance(embeds, Embed):
39
+ embeds = ListNode([embeds])
40
+
41
+ if not isinstance(view, (EasyModifiedViews, NoneType)):
42
+ raise Exception(f'View must be an UI bloc or None, not {type(view)} !')
43
+
44
+ sended_message = await ctx.response.send_message(
45
+ content=str(content),
46
+ ephemeral=hide,
47
+ allowed_mentions=allowed_mentions,
48
+ delete_after=delete,
49
+ embeds=embeds,
50
+ view=view)
51
+
52
+ return sended_message.id
53
+
54
+ async def dshell_defer_interaction(ctx: Interaction, hide: bool = False) -> bool:
55
+ """
56
+ Defer a message interaction on Discord
57
+ """
58
+
59
+ if not isinstance(ctx, Interaction):
60
+ raise Exception(f'Respond to an interaction must be used in an interaction context, not {type(ctx)} !')
61
+
62
+ if not isinstance(hide, bool):
63
+ raise Exception(f'Hide parameter must be a boolean, not {type(hide)} !')
64
+
65
+ await ctx.response.defer(ephemeral=hide)
66
+
67
+ return True
@@ -1,4 +1,5 @@
1
1
  from re import search
2
+ from tkinter import Listbox
2
3
 
3
4
  from discord import Embed, Message, Interaction
4
5
  from discord.ext import commands
@@ -119,7 +120,7 @@ async def dshell_purge_message(ctx: Message, message_number: int, channel=None,
119
120
  await purge_channel.purge(limit=message_number, reason=reason)
120
121
 
121
122
 
122
- async def dshell_edit_message(ctx: Message, message, new_content=None, embeds=None):
123
+ async def dshell_edit_message(ctx: Message, message, new_content=None, embeds=None, view=None) -> int:
123
124
  """
124
125
  Edits a message
125
126
  """
@@ -130,18 +131,21 @@ async def dshell_edit_message(ctx: Message, message, new_content=None, embeds=No
130
131
  if not isinstance(embeds, (ListNode, Embed, NoneType)):
131
132
  raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
132
133
 
134
+ if not isinstance(view, (EasyModifiedViews, NoneType)):
135
+ raise Exception(f'View must be an UI bloc or None, not {type(view)} !')
136
+
133
137
  if embeds is None:
134
138
  embeds = ListNode([])
135
139
 
136
140
  elif isinstance(embeds, Embed):
137
141
  embeds = ListNode([embeds])
138
142
 
139
- await edit_message.edit(content=new_content, embeds=embeds)
143
+ await edit_message.edit(content=new_content, embeds=embeds, view=view)
140
144
 
141
145
  return edit_message.id
142
146
 
143
147
 
144
- async def dshell_get_hystory_messages(ctx: Message, channel=None, limit=None):
148
+ async def dshell_get_hystory_messages(ctx: Message, channel=None, limit=None) -> "ListNode":
145
149
  """
146
150
  Searches for messages matching a regex in a channel
147
151
  """
@@ -40,22 +40,34 @@ class DshellInterpreteur:
40
40
  message = ctx.message if isinstance(ctx, Interaction) else ctx
41
41
  self.env: dict[str, Any] = {
42
42
  '__ret__': None, # environment variables, '__ret__' is used to store the return value of commands
43
- '__guild__': message.channel.guild.name,
44
- '__channel__': message.channel.name,
45
- '__author__': message.author.name,
43
+
44
+ '__author__': message.author.id,
46
45
  '__author_display_name__': message.author.display_name,
47
46
  '__author_avatar__': message.author.display_avatar.url if message.author.display_avatar else None,
48
47
  '__author_discriminator__': message.author.discriminator,
49
48
  '__author_bot__': message.author.bot,
50
49
  '__author_nick__': message.author.nick if hasattr(message.author, 'nick') else None,
51
50
  '__author_id__': message.author.id,
51
+
52
52
  '__message__': message.content,
53
+ '__message_content__': message.content,
53
54
  '__message_id__': message.id,
55
+ '__message_url__': message.jump_url if hasattr(message, 'jump_url') else None,
56
+
57
+ '__channel__': message.channel.id,
54
58
  '__channel_name__': message.channel.name,
55
59
  '__channel_type__': message.channel.type.name if hasattr(message.channel, 'type') else None,
56
60
  '__channel_id__': message.channel.id,
57
61
  '__private_channel__': isinstance(message.channel, PrivateChannel),
58
- } if message is not None else {}
62
+
63
+ '__guild__': message.channel.guild.id,
64
+ '__guild_name__': message.channel.guild.name,
65
+ '__guild_id__': message.channel.guild.id,
66
+ '__guild_member_count__': message.channel.guild.member_count,
67
+ '__guild_icon__': message.channel.guild.icon.url if message.channel.guild.icon else None,
68
+ '__guild_owner_id__': message.channel.guild.owner_id,
69
+ '__guild_description__': message.channel.guild.description,
70
+ } if message is not None or not debug else {} # {} is used in debug mode, when ctx is None
59
71
  self.vars = vars if vars is not None else ''
60
72
  self.ctx: context = ctx
61
73
  if debug:
@@ -393,3 +393,23 @@ def print_ast(ast: list[ASTNode], decalage: int = 0):
393
393
 
394
394
  elif isinstance(i, ParamNode):
395
395
  print(f"{' ' * decalage}PARAM -> {i.body}")
396
+
397
+ elif isinstance(i, UiNode):
398
+ print(f"{' ' * decalage}UI ->")
399
+ print_ast(i.buttons, decalage + 5)
400
+ print_ast(i.selects, decalage + 5)
401
+
402
+ elif isinstance(i, UiButtonNode):
403
+ print(f"{' ' * decalage}BUTTON -> {i.body}")
404
+
405
+ elif isinstance(i, UiSelectNode):
406
+ print(f"{' ' * decalage}SELECT -> {i.body}")
407
+
408
+ elif isinstance(i, SleepNode):
409
+ print(f"{' ' * decalage}SLEEP -> {i.body}")
410
+
411
+ elif isinstance(i, EndNode):
412
+ print(f"{' ' * decalage}END -> ...")
413
+
414
+ else:
415
+ print(f"{' ' * decalage}UNKNOWN NODE {i}")
@@ -31,11 +31,13 @@ dshell_commands: dict[str, Callable] = {
31
31
  "sm": dshell_send_message, # send message
32
32
  "spm": dshell_send_private_message, # send private message
33
33
  "srm": dshell_respond_message, # respond to a message
34
- "sri": dshell_respond_interaction, # respond to an interaction
35
34
  "dm": dshell_delete_message,
36
35
  "pm": dshell_purge_message,
37
36
  "em": dshell_edit_message, # edit message
38
37
 
38
+ "sri": dshell_respond_interaction, # respond to an interaction
39
+ "di": dshell_defer_interaction, # defer an interaction
40
+
39
41
  "cc": dshell_create_text_channel, # create channel
40
42
  "cvc": dshell_create_voice_channel, # create voice channel
41
43
  "dc": dshell_delete_channel, # delete channel
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.2.13.13
3
+ Version: 0.2.13.14
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.13.13
3
+ Version: 0.2.13.14
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.13.13",
8
+ version="0.2.13.14",
9
9
  author="Chronos",
10
10
  author_email="vagabonwalybi@gmail.com",
11
11
  description="A Discord bot interpreter for creating custom commands and automations.",
@@ -1,42 +0,0 @@
1
- __all__ = [
2
- 'dshell_respond_interaction'
3
- ]
4
-
5
- from types import NoneType
6
- from discord import Interaction, Embed
7
- from pycordViews import EasyModifiedViews
8
-
9
-
10
- async def dshell_respond_interaction(ctx: Interaction, content: str = None, delete=None, mention: bool = None, embeds=None, view=None):
11
- """
12
- Responds to a message interaction on Discord
13
- """
14
-
15
- if delete is not None and not isinstance(delete, (int, float)):
16
- raise Exception(f'Delete parameter must be a number (seconds) or None, not {type(delete)} !')
17
-
18
- mention_author = mention if mention is not None else False
19
-
20
- from .._DshellParser.ast_nodes import ListNode
21
-
22
- if not isinstance(embeds, (ListNode, Embed, NoneType)):
23
- raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
24
-
25
- if embeds is None:
26
- embeds = ListNode([])
27
-
28
- elif isinstance(embeds, Embed):
29
- embeds = ListNode([embeds])
30
-
31
- if not isinstance(view, (EasyModifiedViews, NoneType)):
32
- raise Exception(f'Channel must be an UI or None, not {type(view)} !')
33
-
34
- sended_message = await ctx.response.send_message(
35
- content=str(content),
36
- ephemeral=not mention_author,
37
- delete_after=delete,
38
- embeds=embeds,
39
- view=view)
40
-
41
- return sended_message.id
42
-