dshellInterpreter 0.2.13.13__py3-none-any.whl → 0.2.13.14__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.
- Dshell/DISCORD_COMMANDS/dshell_interaction.py +30 -5
- Dshell/DISCORD_COMMANDS/dshell_message.py +7 -3
- Dshell/_DshellInterpreteur/dshell_interpreter.py +16 -4
- Dshell/_DshellParser/dshell_parser.py +20 -0
- Dshell/_DshellTokenizer/dshell_keywords.py +3 -1
- {dshellinterpreter-0.2.13.13.dist-info → dshellinterpreter-0.2.13.14.dist-info}/METADATA +1 -1
- {dshellinterpreter-0.2.13.13.dist-info → dshellinterpreter-0.2.13.14.dist-info}/RECORD +10 -10
- {dshellinterpreter-0.2.13.13.dist-info → dshellinterpreter-0.2.13.14.dist-info}/WHEEL +0 -0
- {dshellinterpreter-0.2.13.13.dist-info → dshellinterpreter-0.2.13.14.dist-info}/licenses/LICENSE +0 -0
- {dshellinterpreter-0.2.13.13.dist-info → dshellinterpreter-0.2.13.14.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
__all__ = [
|
|
2
|
-
'dshell_respond_interaction'
|
|
2
|
+
'dshell_respond_interaction',
|
|
3
|
+
'dshell_defer_interaction'
|
|
3
4
|
]
|
|
4
5
|
|
|
5
6
|
from types import NoneType
|
|
@@ -7,15 +8,24 @@ from discord import Interaction, Embed
|
|
|
7
8
|
from pycordViews import EasyModifiedViews
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
async def dshell_respond_interaction(ctx: Interaction, content: str = None, delete=None,
|
|
11
|
+
async def dshell_respond_interaction(ctx: Interaction, content: str = None, delete=None, mentions: bool = None, hide: bool = False, embeds=None, view=None) -> int:
|
|
11
12
|
"""
|
|
12
13
|
Responds to a message interaction on Discord
|
|
13
14
|
"""
|
|
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
|
+
|
|
15
19
|
if delete is not None and not isinstance(delete, (int, float)):
|
|
16
20
|
raise Exception(f'Delete parameter must be a number (seconds) or None, not {type(delete)} !')
|
|
17
21
|
|
|
18
|
-
|
|
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
|
|
19
29
|
|
|
20
30
|
from .._DshellParser.ast_nodes import ListNode
|
|
21
31
|
|
|
@@ -29,14 +39,29 @@ async def dshell_respond_interaction(ctx: Interaction, content: str = None, dele
|
|
|
29
39
|
embeds = ListNode([embeds])
|
|
30
40
|
|
|
31
41
|
if not isinstance(view, (EasyModifiedViews, NoneType)):
|
|
32
|
-
raise Exception(f'
|
|
42
|
+
raise Exception(f'View must be an UI bloc or None, not {type(view)} !')
|
|
33
43
|
|
|
34
44
|
sended_message = await ctx.response.send_message(
|
|
35
45
|
content=str(content),
|
|
36
|
-
ephemeral=
|
|
46
|
+
ephemeral=hide,
|
|
47
|
+
allowed_mentions=allowed_mentions,
|
|
37
48
|
delete_after=delete,
|
|
38
49
|
embeds=embeds,
|
|
39
50
|
view=view)
|
|
40
51
|
|
|
41
52
|
return sended_message.id
|
|
42
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
|
-
|
|
44
|
-
'
|
|
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
|
-
|
|
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
|
|
@@ -2,25 +2,25 @@ Dshell/__init__.py,sha256=pGd94FPy8kVXH_jH566HhApQPhbPfMPnZXzH_0dPWh0,93
|
|
|
2
2
|
Dshell/_utils.py,sha256=PJ3fwn8IMqUMnW9oTwfr9v4--rzHIhhLQoVVqjwjoJU,23
|
|
3
3
|
Dshell/DISCORD_COMMANDS/__init__.py,sha256=87-YpGU74m-m7AqUQni7PGbw73JRlioQkywW_61Whms,208
|
|
4
4
|
Dshell/DISCORD_COMMANDS/dshell_channel.py,sha256=qpNe3oE5VyLCmOeCjWlt0rvaSBv2yrkmJgrRswrNOZM,15721
|
|
5
|
-
Dshell/DISCORD_COMMANDS/dshell_interaction.py,sha256=
|
|
5
|
+
Dshell/DISCORD_COMMANDS/dshell_interaction.py,sha256=f1DsMeMcI8t_54x-a9mW2pF5RSxNV0hf0ZV-Dt7p_qk,2540
|
|
6
6
|
Dshell/DISCORD_COMMANDS/dshell_member.py,sha256=5Iw-2dydhYMZOw2nx0svZP9JpZWHOXC0qkL9tClJHtw,8840
|
|
7
|
-
Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=
|
|
7
|
+
Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=VsZk-scVn-OgIKNYFCtWnAf5WowG2ODTa_pNG2ZEZgI,7813
|
|
8
8
|
Dshell/DISCORD_COMMANDS/dshell_pastbin.py,sha256=TkWFGRRTvhhJgvwkDFx9Fz4UM2UUFwxyq0laMVx0mUk,881
|
|
9
9
|
Dshell/DISCORD_COMMANDS/dshell_role.py,sha256=t_yRZRD0FKE2gT4dIDIsHz2PSZZztDVEkkqkG_OkNh4,5002
|
|
10
10
|
Dshell/DISCORD_COMMANDS/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
Dshell/DISCORD_COMMANDS/utils/utils_message.py,sha256=Pn0ljyeCvRfY4tlWHrSbIsxSFZZ5J4lDaeVme3WHp9o,1239
|
|
12
12
|
Dshell/DISCORD_COMMANDS/utils/utils_thread.py,sha256=tVl4msEwrWHY-0AytI6eY3JSs-eIFUigDSJfK9mT1ww,1457
|
|
13
13
|
Dshell/_DshellInterpreteur/__init__.py,sha256=xy5-J-R3YmY99JF3NBHTRRLsComFxpjnCA5xacISctU,35
|
|
14
|
-
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=
|
|
14
|
+
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=ukWRqOYU9pmflnlxF8tgOuuU5I0dSXf5t95R4D2AJtc,27650
|
|
15
15
|
Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZxC4,56
|
|
16
16
|
Dshell/_DshellParser/ast_nodes.py,sha256=CXUG0rIJNh4jzMCgCcRqmQwU0WQoESQ-5FkuVtZZndM,17717
|
|
17
|
-
Dshell/_DshellParser/dshell_parser.py,sha256=
|
|
17
|
+
Dshell/_DshellParser/dshell_parser.py,sha256=bNdqNV3A7VEv-hK9CVSDwFFKgS2oPX_7P5uc7TfK2xA,17559
|
|
18
18
|
Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8qrJWw_s,172
|
|
19
|
-
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=
|
|
19
|
+
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=FY9iByZkNSI4r2M6LCDjjx65awZ_iQyFeOvjYmeK-6A,5860
|
|
20
20
|
Dshell/_DshellTokenizer/dshell_token_type.py,sha256=gYIb2XN2YcgeRgmar_rBDS5CGmwfmxihu8mOW_d6lbE,1533
|
|
21
21
|
Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=RrJA2XpcFH2vS6SnRIn5Own_uL5orIDvpq74t8xD3og,7350
|
|
22
|
-
dshellinterpreter-0.2.13.
|
|
23
|
-
dshellinterpreter-0.2.13.
|
|
24
|
-
dshellinterpreter-0.2.13.
|
|
25
|
-
dshellinterpreter-0.2.13.
|
|
26
|
-
dshellinterpreter-0.2.13.
|
|
22
|
+
dshellinterpreter-0.2.13.14.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
|
|
23
|
+
dshellinterpreter-0.2.13.14.dist-info/METADATA,sha256=8e63xZyweFZwrMI-n2DduWjtScIDHp_WelngI3zoD-A,1152
|
|
24
|
+
dshellinterpreter-0.2.13.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
25
|
+
dshellinterpreter-0.2.13.14.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
|
|
26
|
+
dshellinterpreter-0.2.13.14.dist-info/RECORD,,
|
|
File without changes
|
{dshellinterpreter-0.2.13.13.dist-info → dshellinterpreter-0.2.13.14.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.13.dist-info → dshellinterpreter-0.2.13.14.dist-info}/top_level.txt
RENAMED
|
File without changes
|