dshellInterpreter 0.2.13.9__py3-none-any.whl → 0.2.13.11__py3-none-any.whl

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.

@@ -1,8 +1,7 @@
1
1
  from re import search
2
2
 
3
- from discord import Embed, Message
3
+ from discord import Embed, Message, Interaction
4
4
  from discord.ext import commands
5
- from discord.abc import Messageable
6
5
 
7
6
  from pycordViews import EasyModifiedViews
8
7
 
@@ -12,6 +11,7 @@ from .._utils import NoneType
12
11
  __all__ = [
13
12
  'dshell_send_message',
14
13
  'dshell_respond_message',
14
+ 'dshell_respond_interaction',
15
15
  'dshell_delete_message',
16
16
  'dshell_purge_message',
17
17
  'dshell_edit_message',
@@ -42,7 +42,10 @@ async def dshell_send_message(ctx: Message, message=None, delete=None, channel=N
42
42
  if not isinstance(embeds, (ListNode, Embed, NoneType)):
43
43
  raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
44
44
 
45
- if isinstance(embeds, Embed):
45
+ if embeds is None:
46
+ embeds = ListNode([])
47
+
48
+ elif isinstance(embeds, Embed):
46
49
  embeds = ListNode([embeds])
47
50
 
48
51
  if not isinstance(view, (EasyModifiedViews, NoneType)):
@@ -68,15 +71,15 @@ async def dshell_respond_message(ctx: Message, message=None, content: str = None
68
71
 
69
72
  from .._DshellParser.ast_nodes import ListNode
70
73
 
74
+ if not isinstance(embeds, (ListNode, Embed, NoneType)):
75
+ raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
76
+
71
77
  if embeds is None:
72
78
  embeds = ListNode([])
73
79
 
74
80
  elif isinstance(embeds, Embed):
75
81
  embeds = ListNode([embeds])
76
82
 
77
- else:
78
- raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
79
-
80
83
  sended_message = await respond_message.reply(
81
84
  content=str(content),
82
85
  mention_author=mention_author,
@@ -85,6 +88,39 @@ async def dshell_respond_message(ctx: Message, message=None, content: str = None
85
88
 
86
89
  return sended_message.id
87
90
 
91
+ async def dshell_respond_interaction(ctx: Interaction, content: str = None, delete=None, mention: bool = None, embeds=None, view=None):
92
+ """
93
+ Responds to a message interaction on Discord
94
+ """
95
+
96
+ if delete is not None and not isinstance(delete, (int, float)):
97
+ raise Exception(f'Delete parameter must be a number (seconds) or None, not {type(delete)} !')
98
+
99
+ mention_author = mention if mention is not None else False
100
+
101
+ from .._DshellParser.ast_nodes import ListNode
102
+
103
+ if not isinstance(embeds, (ListNode, Embed, NoneType)):
104
+ raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
105
+
106
+ if embeds is None:
107
+ embeds = ListNode([])
108
+
109
+ elif isinstance(embeds, Embed):
110
+ embeds = ListNode([embeds])
111
+
112
+ if not isinstance(view, (EasyModifiedViews, NoneType)):
113
+ raise Exception(f'Channel must be an UI or None, not {type(view)} !')
114
+
115
+ sended_message = await ctx.response.send_message(
116
+ content=str(content),
117
+ ephemeral=not mention_author,
118
+ delete_after=delete,
119
+ embeds=embeds,
120
+ view=view)
121
+
122
+ return sended_message.id
123
+
88
124
  async def dshell_delete_message(ctx: Message, message=None, reason=None, delay=0):
89
125
  """
90
126
  Deletes a message
@@ -123,11 +159,16 @@ async def dshell_edit_message(ctx: Message, message, new_content=None, embeds=No
123
159
  """
124
160
  edit_message = utils_get_message(ctx, message)
125
161
 
162
+ from .._DshellParser.ast_nodes import ListNode
163
+
164
+ if not isinstance(embeds, (ListNode, Embed, NoneType)):
165
+ raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
166
+
126
167
  if embeds is None:
127
- embeds = []
168
+ embeds = ListNode([])
128
169
 
129
170
  elif isinstance(embeds, Embed):
130
- embeds = [embeds]
171
+ embeds = ListNode([embeds])
131
172
 
132
173
  await edit_message.edit(content=new_content, embeds=embeds)
133
174
 
@@ -19,7 +19,7 @@ from .._DshellTokenizer.dshell_token_type import Token
19
19
  from .._DshellTokenizer.dshell_tokenizer import DshellTokenizer
20
20
 
21
21
  All_nodes = TypeVar('All_nodes', IfNode, LoopNode, ElseNode, ElifNode, ArgsCommandNode, VarNode, IdentOperationNode)
22
- context = TypeVar('context', AutoShardedBot, Message, PrivateChannel)
22
+ context = TypeVar('context', AutoShardedBot, Message, PrivateChannel, Interaction)
23
23
  ButtonStyleValues: tuple = tuple(i.name for i in ButtonStyle)
24
24
 
25
25
  class DshellInterpreteur:
@@ -37,24 +37,25 @@ class DshellInterpreteur:
37
37
  :param vars: Optional dictionary of variables to initialize in the interpreter's environment.
38
38
  """
39
39
  self.ast: list[ASTNode] = parse(DshellTokenizer(code).start(), StartNode([]))[0]
40
+ message = ctx.message if isinstance(ctx, Interaction) else ctx
40
41
  self.env: dict[str, Any] = {
41
42
  '__ret__': None, # environment variables, '__ret__' is used to store the return value of commands
42
- '__guild__': ctx.channel.guild.name,
43
- '__channel__': ctx.channel.name,
44
- '__author__': ctx.author.name,
45
- '__author_display_name__': ctx.author.display_name,
46
- '__author_avatar__': ctx.author.display_avatar.url if ctx.author.display_avatar else None,
47
- '__author_discriminator__': ctx.author.discriminator,
48
- '__author_bot__': ctx.author.bot,
49
- '__author_nick__': ctx.author.nick if hasattr(ctx.author, 'nick') else None,
50
- '__author_id__': ctx.author.id,
51
- '__message__': ctx.content,
52
- '__message_id__': ctx.id,
53
- '__channel_name__': ctx.channel.name,
54
- '__channel_type__': ctx.channel.type.name if hasattr(ctx.channel, 'type') else None,
55
- '__channel_id__': ctx.channel.id,
56
- '__private_channel__': isinstance(ctx.channel, PrivateChannel),
57
- } if ctx is not None else {}
43
+ '__guild__': message.channel.guild.name,
44
+ '__channel__': message.channel.name,
45
+ '__author__': message.author.name,
46
+ '__author_display_name__': message.author.display_name,
47
+ '__author_avatar__': message.author.display_avatar.url if message.author.display_avatar else None,
48
+ '__author_discriminator__': message.author.discriminator,
49
+ '__author_bot__': message.author.bot,
50
+ '__author_nick__': message.author.nick if hasattr(message.author, 'nick') else None,
51
+ '__author_id__': message.author.id,
52
+ '__message__': message.content,
53
+ '__message_id__': message.id,
54
+ '__channel_name__': message.channel.name,
55
+ '__channel_type__': message.channel.type.name if hasattr(message.channel, 'type') else None,
56
+ '__channel_id__': message.channel.id,
57
+ '__private_channel__': isinstance(message.channel, PrivateChannel),
58
+ } if message is not None else {}
58
59
  self.vars = vars if vars is not None else ''
59
60
  self.ctx: context = ctx
60
61
  if debug:
@@ -473,7 +474,7 @@ async def ui_button_callback(button: Button, interaction: Interaction, data: dic
473
474
  '__private_channel__': isinstance(interaction.channel, PrivateChannel),
474
475
  }
475
476
  local_env.update(data)
476
- x = DshellInterpreteur(code, interaction.message, debug=False)
477
+ x = DshellInterpreteur(code, interaction, debug=False)
477
478
  x.env.update(local_env)
478
479
  await x.execute()
479
480
  else:
@@ -30,6 +30,7 @@ dshell_commands: dict[str, Callable] = {
30
30
  "sm": dshell_send_message, # send message
31
31
  "spm": dshell_send_private_message, # send private message
32
32
  "srm": dshell_respond_message, # respond to a message
33
+ "sri": dshell_respond_interaction, # respond to an interaction
33
34
  "dm": dshell_delete_message,
34
35
  "pm": dshell_purge_message,
35
36
  "em": dshell_edit_message, # edit message
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.2.13.9
3
+ Version: 0.2.13.11
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
@@ -3,23 +3,23 @@ Dshell/_utils.py,sha256=PJ3fwn8IMqUMnW9oTwfr9v4--rzHIhhLQoVVqjwjoJU,23
3
3
  Dshell/DISCORD_COMMANDS/__init__.py,sha256=8JPQ-6-s8PkaacmOfQgyczUiLM6rUSceHEJ60oNSis0,173
4
4
  Dshell/DISCORD_COMMANDS/dshell_channel.py,sha256=qpNe3oE5VyLCmOeCjWlt0rvaSBv2yrkmJgrRswrNOZM,15721
5
5
  Dshell/DISCORD_COMMANDS/dshell_member.py,sha256=5Iw-2dydhYMZOw2nx0svZP9JpZWHOXC0qkL9tClJHtw,8840
6
- Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=hrIX7Pj0q2cHzgXLnZYVGS5gpyEyfC4CY5sESOzH7a8,7260
6
+ Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=uwE3T-Bqduqp3r4FkJ3fXVMEG-pAJGeGA2wkEhjavB0,8964
7
7
  Dshell/DISCORD_COMMANDS/dshell_pastbin.py,sha256=TkWFGRRTvhhJgvwkDFx9Fz4UM2UUFwxyq0laMVx0mUk,881
8
8
  Dshell/DISCORD_COMMANDS/dshell_role.py,sha256=t_yRZRD0FKE2gT4dIDIsHz2PSZZztDVEkkqkG_OkNh4,5002
9
9
  Dshell/DISCORD_COMMANDS/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  Dshell/DISCORD_COMMANDS/utils/utils_message.py,sha256=Pn0ljyeCvRfY4tlWHrSbIsxSFZZ5J4lDaeVme3WHp9o,1239
11
11
  Dshell/DISCORD_COMMANDS/utils/utils_thread.py,sha256=tVl4msEwrWHY-0AytI6eY3JSs-eIFUigDSJfK9mT1ww,1457
12
12
  Dshell/_DshellInterpreteur/__init__.py,sha256=xy5-J-R3YmY99JF3NBHTRRLsComFxpjnCA5xacISctU,35
13
- Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=B0HSkC8LEauyVoSGBRkp-Nb8HiCKFJ84hprJe_PurpA,26860
13
+ Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=b4_qgOaCfF6U3Pk_LO0yhXm3TY1HZjvfJhxUNUfB24E,27013
14
14
  Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZxC4,56
15
15
  Dshell/_DshellParser/ast_nodes.py,sha256=CXUG0rIJNh4jzMCgCcRqmQwU0WQoESQ-5FkuVtZZndM,17717
16
16
  Dshell/_DshellParser/dshell_parser.py,sha256=73eKwY7iBzBtL6n2IxJcvtSz0xkfE5y1qEffZ2YfXXY,16913
17
17
  Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8qrJWw_s,172
18
- Dshell/_DshellTokenizer/dshell_keywords.py,sha256=HtrOQiND_TdM2pdNNAdjBZK2Lhzm2_9umY2dmKfFMTQ,5675
18
+ Dshell/_DshellTokenizer/dshell_keywords.py,sha256=upwwXwS0OaYhDTAnXSpem2-L4boMEYRncKK315Z5rwI,5744
19
19
  Dshell/_DshellTokenizer/dshell_token_type.py,sha256=gYIb2XN2YcgeRgmar_rBDS5CGmwfmxihu8mOW_d6lbE,1533
20
20
  Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=LZGs4Ytuyx9Galazqtz32lS4Mmu9yZya1B7AzFQAQOk,7150
21
- dshellinterpreter-0.2.13.9.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
22
- dshellinterpreter-0.2.13.9.dist-info/METADATA,sha256=3TN2BtaFb-8w_0s5XU80cxa2a5fSCkp7pbiWUTOJdm8,1151
23
- dshellinterpreter-0.2.13.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
- dshellinterpreter-0.2.13.9.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
25
- dshellinterpreter-0.2.13.9.dist-info/RECORD,,
21
+ dshellinterpreter-0.2.13.11.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
22
+ dshellinterpreter-0.2.13.11.dist-info/METADATA,sha256=cHOGquOrHo_i_mqA3inzNz3_TPbbOeai4fcj6i0_BNA,1152
23
+ dshellinterpreter-0.2.13.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
+ dshellinterpreter-0.2.13.11.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
25
+ dshellinterpreter-0.2.13.11.dist-info/RECORD,,