dshellInterpreter 0.2.14.1__py3-none-any.whl → 0.2.14.2__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_channel.py +4 -3
- Dshell/DISCORD_COMMANDS/dshell_interaction.py +15 -2
- Dshell/_DshellInterpreteur/dshell_interpreter.py +58 -14
- Dshell/_DshellTokenizer/dshell_keywords.py +1 -0
- {dshellinterpreter-0.2.14.1.dist-info → dshellinterpreter-0.2.14.2.dist-info}/METADATA +1 -1
- {dshellinterpreter-0.2.14.1.dist-info → dshellinterpreter-0.2.14.2.dist-info}/RECORD +9 -9
- {dshellinterpreter-0.2.14.1.dist-info → dshellinterpreter-0.2.14.2.dist-info}/WHEEL +0 -0
- {dshellinterpreter-0.2.14.1.dist-info → dshellinterpreter-0.2.14.2.dist-info}/licenses/LICENSE +0 -0
- {dshellinterpreter-0.2.14.1.dist-info → dshellinterpreter-0.2.14.2.dist-info}/top_level.txt +0 -0
|
@@ -304,9 +304,10 @@ async def dshell_create_thread_message(ctx: Message,
|
|
|
304
304
|
if not isinstance(slowmode, _MissingSentinel) and slowmode < 0:
|
|
305
305
|
raise Exception("Slowmode delay must be a positive integer !")
|
|
306
306
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
307
|
+
m = await message.fetch()
|
|
308
|
+
thread = await m.create_thread(name=name,
|
|
309
|
+
auto_archive_duration=archive,
|
|
310
|
+
slowmode_delay=slowmode)
|
|
310
311
|
|
|
311
312
|
return thread.id
|
|
312
313
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
__all__ = [
|
|
2
2
|
'dshell_respond_interaction',
|
|
3
|
-
'dshell_defer_interaction'
|
|
3
|
+
'dshell_defer_interaction',
|
|
4
|
+
'dshell_delete_original_message'
|
|
4
5
|
]
|
|
5
6
|
|
|
6
7
|
from types import NoneType
|
|
@@ -76,4 +77,16 @@ async def dshell_defer_interaction(ctx: Interaction, hide: bool = False) -> bool
|
|
|
76
77
|
|
|
77
78
|
await ctx.response.defer(ephemeral=hide)
|
|
78
79
|
|
|
79
|
-
return True
|
|
80
|
+
return True
|
|
81
|
+
|
|
82
|
+
async def dshell_delete_original_message(ctx: Interaction) -> int:
|
|
83
|
+
"""
|
|
84
|
+
Delete the original message of an interaction on Discord
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
if not isinstance(ctx, Interaction):
|
|
88
|
+
raise Exception(f'Respond to an interaction must be used in an interaction context, not {type(ctx)} !')
|
|
89
|
+
|
|
90
|
+
await ctx.delete_original_message()
|
|
91
|
+
|
|
92
|
+
return ctx.message.id
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
from asyncio import sleep
|
|
2
2
|
from re import findall
|
|
3
|
-
from typing import TypeVar, Union, Any, Optional, Callable
|
|
3
|
+
from typing import TypeVar, Union, Any, Optional, Callable, Generator
|
|
4
4
|
from random import choice
|
|
5
5
|
from string import ascii_letters, digits
|
|
6
6
|
from copy import deepcopy
|
|
7
7
|
from pycordViews import EasyModifiedViews
|
|
8
|
+
from pycordViews.views.errors import CustomIDNotFound
|
|
8
9
|
|
|
9
10
|
from discord import AutoShardedBot, Embed, Colour, PermissionOverwrite, Permissions, Guild, Member, Role, Message, Interaction, ButtonStyle
|
|
10
11
|
from discord.ui import Button
|
|
@@ -146,7 +147,11 @@ class DshellInterpreteur:
|
|
|
146
147
|
self.env[node.name.value] = build_permission(first_node.body, self)
|
|
147
148
|
|
|
148
149
|
elif isinstance(first_node, UiNode):
|
|
149
|
-
|
|
150
|
+
# rebuild the UI if it already exists
|
|
151
|
+
if node.name.value in self.env and isinstance(self.env[node.name.value], EasyModifiedViews):
|
|
152
|
+
self.env[node.name.value] = rebuild_ui(first_node, self.env[node.name.value], self)
|
|
153
|
+
else:
|
|
154
|
+
self.env[node.name.value] = build_ui(first_node, self)
|
|
150
155
|
|
|
151
156
|
elif isinstance(first_node, LengthNode):
|
|
152
157
|
self.env[node.name.value] = length(first_node)
|
|
@@ -448,37 +453,77 @@ def build_colour(color: Union[int, ListNode]) -> Union[Colour, int]:
|
|
|
448
453
|
else:
|
|
449
454
|
raise TypeError(f"Color must be an integer or a ListNode, not {type(color)} !")
|
|
450
455
|
|
|
451
|
-
|
|
452
|
-
def build_ui(ui_node: UiNode, interpreter: DshellInterpreteur) -> EasyModifiedViews:
|
|
456
|
+
def build_ui_parameters(ui_node: UiNode, interpreter: DshellInterpreteur) -> Generator[tuple[list[Any], dict[str, list[Any]], Optional[str]]]:
|
|
453
457
|
"""
|
|
454
|
-
Builds a UI component from the UiNode.
|
|
458
|
+
Builds the parameters for a UI component from the UiNode.
|
|
455
459
|
Can accept buttons and select menus.
|
|
456
460
|
:param ui_node:
|
|
457
461
|
:param interpreter:
|
|
458
462
|
:return:
|
|
459
463
|
"""
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
args_button: dict[str, list[Any]] = regroupe_commandes(component.body, interpreter, normalise=True)[0]
|
|
464
|
+
for ident_component in range(len(ui_node.buttons)):
|
|
465
|
+
args_button: dict[str, list[Any]] = \
|
|
466
|
+
regroupe_commandes(ui_node.buttons[ident_component].body, interpreter, normalise=True)[0]
|
|
464
467
|
args_button.pop('--*', ())
|
|
465
468
|
|
|
466
469
|
code = args_button.pop('code', None)
|
|
467
470
|
style = args_button.pop('style', 'primary').lower()
|
|
471
|
+
custom_id = args_button.pop('custom_id', str(ident_component))
|
|
472
|
+
|
|
473
|
+
if not isinstance(custom_id, str):
|
|
474
|
+
raise TypeError(f"Button custom_id must be a string, not {type(custom_id)} !")
|
|
475
|
+
|
|
468
476
|
if style not in ButtonStyleValues:
|
|
469
477
|
raise ValueError(f"Button style must be one of {', '.join(ButtonStyleValues)}, not '{style}' !")
|
|
478
|
+
|
|
479
|
+
args_button['custom_id'] = custom_id
|
|
470
480
|
args_button['style'] = ButtonStyle[style]
|
|
471
481
|
args = args_button.pop('*', ())
|
|
472
|
-
|
|
482
|
+
yield args, args_button, code
|
|
483
|
+
|
|
484
|
+
def build_ui(ui_node: UiNode, interpreter: DshellInterpreteur) -> EasyModifiedViews:
|
|
485
|
+
"""
|
|
486
|
+
Builds a UI component from the UiNode.
|
|
487
|
+
Can accept buttons and select menus.
|
|
488
|
+
:param ui_node:
|
|
489
|
+
:param interpreter:
|
|
490
|
+
:return:
|
|
491
|
+
"""
|
|
492
|
+
view = EasyModifiedViews()
|
|
473
493
|
|
|
474
|
-
|
|
475
|
-
b
|
|
494
|
+
for args, args_button, code in build_ui_parameters(ui_node, interpreter):
|
|
495
|
+
b = Button(**args_button)
|
|
476
496
|
|
|
477
497
|
view.add_items(b)
|
|
478
|
-
view.set_callable(custom_id, _callable=ui_button_callback, data={'code': code})
|
|
498
|
+
view.set_callable(b.custom_id, _callable=ui_button_callback, data={'code': code})
|
|
499
|
+
|
|
500
|
+
return view
|
|
501
|
+
|
|
502
|
+
def rebuild_ui(ui_node : UiNode, view: EasyModifiedViews, interpreter: DshellInterpreteur) -> EasyModifiedViews:
|
|
503
|
+
"""
|
|
504
|
+
Rebuilds a UI component from an existing EasyModifiedViews.
|
|
505
|
+
:param view:
|
|
506
|
+
:param interpreter:
|
|
507
|
+
:return:
|
|
508
|
+
"""
|
|
509
|
+
for args, args_button, code in build_ui_parameters(ui_node, interpreter):
|
|
510
|
+
try:
|
|
511
|
+
ui = view.get_ui(args_button['custom_id'])
|
|
512
|
+
except CustomIDNotFound:
|
|
513
|
+
raise ValueError(f"Button with custom_id '{args_button['custom_id']}' not found in the view !")
|
|
514
|
+
|
|
515
|
+
ui.view.label = args_button.get('label', ui.view.label)
|
|
516
|
+
ui.view.style = args_button.get('style', ui.view.style)
|
|
517
|
+
ui.view.emoji = args_button.get('emoji', ui.view.emoji)
|
|
518
|
+
ui.view.disabled = args_button.get('disabled', ui.view.disabled)
|
|
519
|
+
ui.view.url = args_button.get('url', ui.view.url)
|
|
520
|
+
ui.view.row = args_button.get('row', ui.view.row)
|
|
521
|
+
new_code = code if code is not None else view.get_callable_data(args_button['custom_id'])['code']
|
|
522
|
+
view.set_callable(args_button['custom_id'], _callable=ui_button_callback, data={'code': args_button.get('code', code)})
|
|
479
523
|
|
|
480
524
|
return view
|
|
481
525
|
|
|
526
|
+
|
|
482
527
|
async def ui_button_callback(button: Button, interaction: Interaction, data: dict[str, Any]):
|
|
483
528
|
"""
|
|
484
529
|
Callback for UI buttons.
|
|
@@ -488,7 +533,6 @@ async def ui_button_callback(button: Button, interaction: Interaction, data: dic
|
|
|
488
533
|
:param data:
|
|
489
534
|
:return:
|
|
490
535
|
"""
|
|
491
|
-
print(data)
|
|
492
536
|
code = data.pop('code', None)
|
|
493
537
|
if code is not None:
|
|
494
538
|
local_env = {
|
|
@@ -37,6 +37,7 @@ dshell_commands: dict[str, Callable] = {
|
|
|
37
37
|
|
|
38
38
|
"sri": dshell_respond_interaction, # respond to an interaction
|
|
39
39
|
"sdi": dshell_defer_interaction, # defer an interaction
|
|
40
|
+
"dom": dshell_delete_original_message, # delete original interaction message
|
|
40
41
|
|
|
41
42
|
"cc": dshell_create_text_channel, # create channel
|
|
42
43
|
"cvc": dshell_create_voice_channel, # create voice channel
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
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
|
-
Dshell/DISCORD_COMMANDS/dshell_channel.py,sha256=
|
|
5
|
-
Dshell/DISCORD_COMMANDS/dshell_interaction.py,sha256=
|
|
4
|
+
Dshell/DISCORD_COMMANDS/dshell_channel.py,sha256=PDXpxrRRWPSucdp_3ITJk0Ur3coneRJKWEl2i7GZ2EM,15696
|
|
5
|
+
Dshell/DISCORD_COMMANDS/dshell_interaction.py,sha256=gYojAOH5hl-ZL6Y1lEb87-H9MtOa8sb_VAV4_iiYfWA,3649
|
|
6
6
|
Dshell/DISCORD_COMMANDS/dshell_member.py,sha256=5Iw-2dydhYMZOw2nx0svZP9JpZWHOXC0qkL9tClJHtw,8840
|
|
7
7
|
Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=zcWl6Y1W31h9MTHS-j9tLDwcrRiE_wGOu78zu2k0y9I,9101
|
|
8
8
|
Dshell/DISCORD_COMMANDS/dshell_pastbin.py,sha256=H0tUJOwdzYBXvxqipK3mzoNZUKrSLcVm4EZlWbBRScs,796
|
|
@@ -11,16 +11,16 @@ Dshell/DISCORD_COMMANDS/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
|
|
|
11
11
|
Dshell/DISCORD_COMMANDS/utils/utils_message.py,sha256=cQvJ15f49ddOjybARwkJKNFe3ITYQciF-pZHERFPkr0,2964
|
|
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=sfNZgBFRTir4DaDCmAtFd_BeGQIWtAV90rdISK1Edi8,31050
|
|
15
15
|
Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZxC4,56
|
|
16
16
|
Dshell/_DshellParser/ast_nodes.py,sha256=fU6BVe6w78ZhYib7SGR7iAfTqWqS2kvwZ0d4wMxxOHk,18366
|
|
17
17
|
Dshell/_DshellParser/dshell_parser.py,sha256=ZSSRheiNNR1zumxBK_tqlnUPjJ7ZIE6S-K5aJPp4TjM,21887
|
|
18
18
|
Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8qrJWw_s,172
|
|
19
|
-
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=
|
|
19
|
+
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=7oeSKLXCsPRpyU31skCerOUMzd2cdm-GwofpmgTPkD0,5961
|
|
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.14.
|
|
23
|
-
dshellinterpreter-0.2.14.
|
|
24
|
-
dshellinterpreter-0.2.14.
|
|
25
|
-
dshellinterpreter-0.2.14.
|
|
26
|
-
dshellinterpreter-0.2.14.
|
|
22
|
+
dshellinterpreter-0.2.14.2.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
|
|
23
|
+
dshellinterpreter-0.2.14.2.dist-info/METADATA,sha256=wylXmB0i8_Iy_xnlZogu0pugK0fe2s_dyn3FVzru4zM,1151
|
|
24
|
+
dshellinterpreter-0.2.14.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
25
|
+
dshellinterpreter-0.2.14.2.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
|
|
26
|
+
dshellinterpreter-0.2.14.2.dist-info/RECORD,,
|
|
File without changes
|
{dshellinterpreter-0.2.14.1.dist-info → dshellinterpreter-0.2.14.2.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|