dshellInterpreter 0.2.13.11__tar.gz → 0.2.13.13__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.
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/DISCORD_COMMANDS/__init__.py +1 -0
- dshellinterpreter-0.2.13.13/Dshell/DISCORD_COMMANDS/dshell_interaction.py +42 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/DISCORD_COMMANDS/dshell_message.py +0 -34
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_DshellTokenizer/dshell_keywords.py +1 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_DshellTokenizer/dshell_tokenizer.py +27 -24
- {dshellinterpreter-0.2.13.11/dshellInterpreter.egg-info → dshellinterpreter-0.2.13.13}/PKG-INFO +1 -1
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13/dshellInterpreter.egg-info}/PKG-INFO +1 -1
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/dshellInterpreter.egg-info/SOURCES.txt +1 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/setup.py +1 -1
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/DISCORD_COMMANDS/dshell_channel.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/DISCORD_COMMANDS/dshell_member.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/DISCORD_COMMANDS/dshell_pastbin.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/DISCORD_COMMANDS/dshell_role.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/DISCORD_COMMANDS/utils/__init__.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/DISCORD_COMMANDS/utils/utils_message.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/DISCORD_COMMANDS/utils/utils_thread.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_DshellInterpreteur/__init__.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_DshellInterpreteur/dshell_interpreter.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_DshellParser/__init__.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_DshellParser/ast_nodes.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_DshellParser/dshell_parser.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_DshellTokenizer/__init__.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_DshellTokenizer/dshell_token_type.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/__init__.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_utils.py +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/LICENSE +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/README.md +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/dshellInterpreter.egg-info/dependency_links.txt +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/dshellInterpreter.egg-info/requires.txt +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/dshellInterpreter.egg-info/top_level.txt +0 -0
- {dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/setup.cfg +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
|
|
@@ -11,7 +11,6 @@ from .._utils import NoneType
|
|
|
11
11
|
__all__ = [
|
|
12
12
|
'dshell_send_message',
|
|
13
13
|
'dshell_respond_message',
|
|
14
|
-
'dshell_respond_interaction',
|
|
15
14
|
'dshell_delete_message',
|
|
16
15
|
'dshell_purge_message',
|
|
17
16
|
'dshell_edit_message',
|
|
@@ -88,39 +87,6 @@ async def dshell_respond_message(ctx: Message, message=None, content: str = None
|
|
|
88
87
|
|
|
89
88
|
return sended_message.id
|
|
90
89
|
|
|
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
|
-
|
|
124
90
|
async def dshell_delete_message(ctx: Message, message=None, reason=None, delay=0):
|
|
125
91
|
"""
|
|
126
92
|
Deletes a message
|
|
@@ -15,6 +15,7 @@ from ..DISCORD_COMMANDS.dshell_member import *
|
|
|
15
15
|
from ..DISCORD_COMMANDS.dshell_message import *
|
|
16
16
|
from ..DISCORD_COMMANDS.dshell_pastbin import *
|
|
17
17
|
from ..DISCORD_COMMANDS.dshell_role import *
|
|
18
|
+
from ..DISCORD_COMMANDS.dshell_interaction import *
|
|
18
19
|
|
|
19
20
|
dshell_keyword: set[str] = {
|
|
20
21
|
'if', 'else', 'elif', 'loop', '#end', 'var', '#loop', '#if', 'sleep', 'param', '#param'
|
|
@@ -14,9 +14,9 @@ from .dshell_token_type import Token
|
|
|
14
14
|
MASK_CHARACTER = '§'
|
|
15
15
|
|
|
16
16
|
table_regex: dict[DTT, Pattern] = {
|
|
17
|
-
DTT.COMMENT: compile(r"::(.*?)"),
|
|
18
17
|
DTT.ENGLOBE_SEPARATOR: compile(rf"--\*\w+\s*(.*?)\s*(?=--|$)"),
|
|
19
|
-
DTT.STR: compile(r'"(
|
|
18
|
+
DTT.STR: compile(r'"((?:[^\\"]|\\.)*)"', flags=DOTALL),
|
|
19
|
+
DTT.COMMENT: compile(r"::(.*?)$"),
|
|
20
20
|
DTT.LIST: compile(r"\[(.*?)\]"),
|
|
21
21
|
DTT.CALL_ARGS: compile(r"\((.*?)\)"),
|
|
22
22
|
DTT.MENTION: compile(r'<(?:@!?|@&|#)([0-9]+)>'),
|
|
@@ -76,23 +76,26 @@ class DshellTokenizer:
|
|
|
76
76
|
token = Token(token_type, match.group(1), (line_number, start_match)) # on enregistre son token
|
|
77
77
|
tokens_par_ligne.append(token)
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
DTT.CALL_ARGS): # si c'est un regroupement de donnée, on tokenize ce qu'il contient
|
|
82
|
-
result = self.tokenizer([token.value])
|
|
83
|
-
token.value = result[0] if len(
|
|
84
|
-
result) > 0 else result # gère si la structure de donnée est vide ou non
|
|
79
|
+
if token_type == DTT.STR:
|
|
80
|
+
token.value = token.value.replace(r'\"', '"')
|
|
85
81
|
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
if token_type in (
|
|
83
|
+
DTT.LIST,
|
|
84
|
+
DTT.CALL_ARGS): # si c'est un regroupement de donnée, on tokenize ce qu'il contient
|
|
85
|
+
result = self.tokenizer([token.value])
|
|
86
|
+
token.value = result[0] if len(
|
|
87
|
+
result) > 0 else result # gère si la structure de donnée est vide ou non
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
for token_in_list in token.value:
|
|
90
|
+
token_in_list.position = (line_number, token_in_list.position[1])
|
|
91
|
+
|
|
92
|
+
for token_in_line in range(len(tokens_par_ligne)-1):
|
|
93
|
+
if tokens_par_ligne[token_in_line].position[1] > start_match:
|
|
94
|
+
str_tokens_in_list = tokens_par_ligne[token_in_line:-1]
|
|
95
|
+
tokens_par_ligne = tokens_par_ligne[:token_in_line] + [tokens_par_ligne[-1]]
|
|
96
|
+
token.value.extend(str_tokens_in_list)
|
|
97
|
+
token.value.sort(key=lambda t: t.position[1]) # trie les tokens par rapport à leur position
|
|
98
|
+
break
|
|
96
99
|
|
|
97
100
|
len_match = len(match.group(0)) # longueur du match trouvé
|
|
98
101
|
ligne = ligne[:start_match] + (MASK_CHARACTER * len_match) + ligne[
|
|
@@ -112,6 +115,7 @@ class DshellTokenizer:
|
|
|
112
115
|
str]:
|
|
113
116
|
"""
|
|
114
117
|
Sépare les commandes en une liste en respectant les chaînes entre guillemets.
|
|
118
|
+
Echapper les caractères regroupants avec un antislash (\) pour les inclure dans la chaîne.
|
|
115
119
|
:param commande: La chaîne de caractères à découper.
|
|
116
120
|
:param global_split: Le séparateur utilisé (par défaut '\n').
|
|
117
121
|
:param garder_carractere_regroupant: Si False, enlève les guillemets autour des chaînes.
|
|
@@ -121,14 +125,13 @@ class DshellTokenizer:
|
|
|
121
125
|
|
|
122
126
|
commandes: str = commande.strip()
|
|
123
127
|
remplacement_temporaire = '[REMPLACER]'
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
# current_command_text = [i[1: -1] for i in
|
|
128
|
-
# entre_carractere_regroupant.copy()] # enregistre les parties entre guillemets pour cette commande
|
|
128
|
+
pattern_find_regrouped_part = compile(fr'({carractere_regroupant}(?:[^\\{carractere_regroupant}]|\\.)*{carractere_regroupant})', flags=DOTALL)
|
|
129
|
+
entre_caractere_regroupant = findall(pattern_find_regrouped_part, commandes) # repère les parties entre guillemets et les save
|
|
129
130
|
|
|
130
|
-
res = sub(
|
|
131
|
-
|
|
131
|
+
res = sub(pattern_find_regrouped_part,
|
|
132
|
+
remplacement_temporaire,
|
|
133
|
+
commandes,
|
|
134
|
+
) # remplace les parties entre guillemets
|
|
132
135
|
|
|
133
136
|
res = res.split(global_split) # split les commandes sans les guillemets
|
|
134
137
|
|
{dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/dshellInterpreter.egg-info/SOURCES.txt
RENAMED
|
@@ -5,6 +5,7 @@ Dshell/__init__.py
|
|
|
5
5
|
Dshell/_utils.py
|
|
6
6
|
Dshell/DISCORD_COMMANDS/__init__.py
|
|
7
7
|
Dshell/DISCORD_COMMANDS/dshell_channel.py
|
|
8
|
+
Dshell/DISCORD_COMMANDS/dshell_interaction.py
|
|
8
9
|
Dshell/DISCORD_COMMANDS/dshell_member.py
|
|
9
10
|
Dshell/DISCORD_COMMANDS/dshell_message.py
|
|
10
11
|
Dshell/DISCORD_COMMANDS/dshell_pastbin.py
|
|
@@ -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.
|
|
8
|
+
version="0.2.13.13",
|
|
9
9
|
author="Chronos",
|
|
10
10
|
author_email="vagabonwalybi@gmail.com",
|
|
11
11
|
description="A Discord bot interpreter for creating custom commands and automations.",
|
|
File without changes
|
{dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/DISCORD_COMMANDS/dshell_member.py
RENAMED
|
File without changes
|
|
File without changes
|
{dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/DISCORD_COMMANDS/dshell_role.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_DshellInterpreteur/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_DshellParser/__init__.py
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_DshellParser/ast_nodes.py
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_DshellParser/dshell_parser.py
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/Dshell/_DshellTokenizer/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/dshellInterpreter.egg-info/requires.txt
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.11 → dshellinterpreter-0.2.13.13}/dshellInterpreter.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|