dshellInterpreter 0.2.13.15__tar.gz → 0.2.13.17__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.15 → dshellinterpreter-0.2.13.17}/Dshell/DISCORD_COMMANDS/dshell_pastbin.py +5 -7
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/_DshellInterpreteur/dshell_interpreter.py +25 -1
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/_DshellParser/ast_nodes.py +24 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/_DshellParser/dshell_parser.py +74 -4
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/_DshellTokenizer/dshell_keywords.py +2 -2
- {dshellinterpreter-0.2.13.15/dshellInterpreter.egg-info → dshellinterpreter-0.2.13.17}/PKG-INFO +1 -1
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17/dshellInterpreter.egg-info}/PKG-INFO +1 -1
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/setup.py +1 -1
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/DISCORD_COMMANDS/__init__.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/DISCORD_COMMANDS/dshell_channel.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/DISCORD_COMMANDS/dshell_interaction.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/DISCORD_COMMANDS/dshell_member.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/DISCORD_COMMANDS/dshell_message.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/DISCORD_COMMANDS/dshell_role.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/DISCORD_COMMANDS/utils/__init__.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/DISCORD_COMMANDS/utils/utils_message.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/DISCORD_COMMANDS/utils/utils_thread.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/_DshellInterpreteur/__init__.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/_DshellParser/__init__.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/_DshellTokenizer/__init__.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/_DshellTokenizer/dshell_token_type.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/_DshellTokenizer/dshell_tokenizer.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/__init__.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/_utils.py +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/LICENSE +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/README.md +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/dshellInterpreter.egg-info/SOURCES.txt +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/dshellInterpreter.egg-info/dependency_links.txt +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/dshellInterpreter.egg-info/requires.txt +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/dshellInterpreter.egg-info/top_level.txt +0 -0
- {dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/setup.cfg +0 -0
|
@@ -6,14 +6,16 @@ __all__ = [
|
|
|
6
6
|
]
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
async def dshell_get_pastbin(ctx: Message, code: str):
|
|
9
|
+
async def dshell_get_pastbin(ctx: Message, code: str) -> "ListNode":
|
|
10
10
|
"""
|
|
11
11
|
Get a pastbin from a code snippet.
|
|
12
12
|
"""
|
|
13
13
|
if not isinstance(code, str):
|
|
14
14
|
raise Exception(f'Code must be a string, not {type(code)} !')
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
from .._DshellParser.ast_nodes import ListNode
|
|
17
|
+
|
|
18
|
+
content = ListNode([]) # Initialize content to an empty string
|
|
17
19
|
|
|
18
20
|
with get(f"https://pastebin.com/raw/{code}", stream=True, timeout=10) as response:
|
|
19
21
|
|
|
@@ -21,10 +23,6 @@ async def dshell_get_pastbin(ctx: Message, code: str):
|
|
|
21
23
|
raise Exception(f"Failed to retrieve pastbin with code {code} !")
|
|
22
24
|
|
|
23
25
|
for line in response.iter_lines(decode_unicode=True, chunk_size=512):
|
|
24
|
-
|
|
25
|
-
if len_content < 4000 and len_content + len(line) <= 4000:
|
|
26
|
-
content += line + '\n'
|
|
27
|
-
else:
|
|
28
|
-
break
|
|
26
|
+
content.add(line)
|
|
29
27
|
|
|
30
28
|
return content
|
|
@@ -4,7 +4,7 @@ from typing import TypeVar, Union, Any, Optional, Callable
|
|
|
4
4
|
from random import choice
|
|
5
5
|
from string import ascii_letters, digits
|
|
6
6
|
from copy import deepcopy
|
|
7
|
-
from pycordViews import
|
|
7
|
+
from pycordViews import EasyModifiedViews
|
|
8
8
|
|
|
9
9
|
from discord import AutoShardedBot, Embed, Colour, PermissionOverwrite, Permissions, Guild, Member, Role, Message, Interaction, ButtonStyle
|
|
10
10
|
from discord.ui import Button
|
|
@@ -63,10 +63,18 @@ class DshellInterpreteur:
|
|
|
63
63
|
'__guild__': message.channel.guild.id,
|
|
64
64
|
'__guild_name__': message.channel.guild.name,
|
|
65
65
|
'__guild_id__': message.channel.guild.id,
|
|
66
|
+
'__guild_members__': ListNode([member.id for member in message.channel.guild.members]),
|
|
66
67
|
'__guild_member_count__': message.channel.guild.member_count,
|
|
67
68
|
'__guild_icon__': message.channel.guild.icon.url if message.channel.guild.icon else None,
|
|
68
69
|
'__guild_owner_id__': message.channel.guild.owner_id,
|
|
69
70
|
'__guild_description__': message.channel.guild.description,
|
|
71
|
+
'__guild_roles__': ListNode([role.id for role in message.channel.guild.roles]),
|
|
72
|
+
'__guild_roles_count__': len(message.channel.guild.roles),
|
|
73
|
+
'__guild_emojis__': ListNode([emoji.id for emoji in message.channel.guild.emojis]),
|
|
74
|
+
'__guild_emojis_count__': len(message.channel.guild.emojis),
|
|
75
|
+
'__guild_channels__': ListNode([channel.id for channel in message.channel.guild.channels]),
|
|
76
|
+
'__guild_channels_count__': len(message.channel.guild.channels),
|
|
77
|
+
|
|
70
78
|
} if message is not None or not debug else {} # {} is used in debug mode, when ctx is None
|
|
71
79
|
self.vars = vars if vars is not None else ''
|
|
72
80
|
self.ctx: context = ctx
|
|
@@ -140,6 +148,9 @@ class DshellInterpreteur:
|
|
|
140
148
|
elif isinstance(first_node, UiNode):
|
|
141
149
|
self.env[node.name.value] = build_ui(first_node, self)
|
|
142
150
|
|
|
151
|
+
elif isinstance(first_node, LengthNode):
|
|
152
|
+
self.env[node.name.value] = length(first_node.body)
|
|
153
|
+
|
|
143
154
|
else:
|
|
144
155
|
self.env[node.name.value] = eval_expression(node.body, self)
|
|
145
156
|
|
|
@@ -382,6 +393,19 @@ def regroupe_commandes(body: list[Token], interpreter: DshellInterpreteur, norma
|
|
|
382
393
|
|
|
383
394
|
return list_tokens
|
|
384
395
|
|
|
396
|
+
def length(variable : LengthNode) -> int:
|
|
397
|
+
"""
|
|
398
|
+
Count characters or items in string/list
|
|
399
|
+
:param variable:
|
|
400
|
+
:return:
|
|
401
|
+
"""
|
|
402
|
+
if not isinstance(variable.body, ListNode) and variable.body.type not in (DTT.STR, DTT.IDENT):
|
|
403
|
+
raise Exception(f'Length take string, ident or list, not {type(variable.body)} !')
|
|
404
|
+
|
|
405
|
+
if isinstance(variable.body, ListNode):
|
|
406
|
+
return len(variable.body)
|
|
407
|
+
else:
|
|
408
|
+
return len(variable.body.value)
|
|
385
409
|
|
|
386
410
|
def build_embed(body: list[Token], fields: list[FieldEmbedNode], interpreter: DshellInterpreteur) -> Embed:
|
|
387
411
|
"""
|
{dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/_DshellParser/ast_nodes.py
RENAMED
|
@@ -5,6 +5,7 @@ from .._DshellTokenizer.dshell_token_type import Token
|
|
|
5
5
|
|
|
6
6
|
__all__ = [
|
|
7
7
|
'ASTNode',
|
|
8
|
+
'LengthNode',
|
|
8
9
|
'StartNode',
|
|
9
10
|
'ElseNode',
|
|
10
11
|
'ElifNode',
|
|
@@ -257,6 +258,29 @@ class VarNode(ASTNode):
|
|
|
257
258
|
"body": [token.to_dict() for token in self.body]
|
|
258
259
|
}
|
|
259
260
|
|
|
261
|
+
class LengthNode(ASTNode):
|
|
262
|
+
"""
|
|
263
|
+
Node representing the length operation in the AST.
|
|
264
|
+
"""
|
|
265
|
+
|
|
266
|
+
def __init__(self, body: Token):
|
|
267
|
+
"""
|
|
268
|
+
:param body: list of tokens representing the body of the length operation
|
|
269
|
+
"""
|
|
270
|
+
self.body = body
|
|
271
|
+
|
|
272
|
+
def __repr__(self):
|
|
273
|
+
return f"<LENGTH> - {self.body}"
|
|
274
|
+
|
|
275
|
+
def to_dict(self):
|
|
276
|
+
"""
|
|
277
|
+
Convert the LengthNode to a dictionary representation.
|
|
278
|
+
:return: Dictionary representation of the LengthNode.
|
|
279
|
+
"""
|
|
280
|
+
return {
|
|
281
|
+
"type": "LengthNode",
|
|
282
|
+
"body": self.body.to_dict()
|
|
283
|
+
}
|
|
260
284
|
|
|
261
285
|
class EndNode(ASTNode):
|
|
262
286
|
"""
|
{dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/_DshellParser/dshell_parser.py
RENAMED
|
@@ -10,6 +10,7 @@ __all__ = [
|
|
|
10
10
|
from typing import Union
|
|
11
11
|
|
|
12
12
|
from .ast_nodes import (ASTNode,
|
|
13
|
+
LengthNode,
|
|
13
14
|
CommandNode,
|
|
14
15
|
IfNode,
|
|
15
16
|
LoopNode,
|
|
@@ -40,7 +41,7 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
40
41
|
:param start_node: the node where to start the parsing
|
|
41
42
|
"""
|
|
42
43
|
pointeur = 0 # pointeur sur les listes de tokens pour savoir ou parser
|
|
43
|
-
blocks
|
|
44
|
+
blocks = [start_node] # liste d'imbrication des blocks pour gérer l'imbrication
|
|
44
45
|
len_token_lines = len(token_lines)
|
|
45
46
|
|
|
46
47
|
while pointeur < len_token_lines:
|
|
@@ -50,6 +51,8 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
50
51
|
last_block = blocks[-1]
|
|
51
52
|
|
|
52
53
|
if first_token_line.type == DTT.COMMAND: # si le token est une comande
|
|
54
|
+
if len(tokens_by_line) <= 1:
|
|
55
|
+
raise Exception(f'[{first_token_line.value.upper()}] take one or more arguments on line {first_token_line.position} !')
|
|
53
56
|
body = tokens_by_line[1:] # on récupère ses arguments
|
|
54
57
|
last_block.body.append(CommandNode(first_token_line.value,
|
|
55
58
|
ArgsCommandNode(body))) # on ajoute la commande au body du dernier bloc
|
|
@@ -59,6 +62,9 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
59
62
|
elif first_token_line.type == DTT.KEYWORD: # si c'est un mot clé
|
|
60
63
|
|
|
61
64
|
if first_token_line.value == 'if': # si c'est une condition
|
|
65
|
+
if len(tokens_by_line) <= 1:
|
|
66
|
+
raise SyntaxError(f'[IF] Take one or more arguments on line {first_token_line.position} !')
|
|
67
|
+
|
|
62
68
|
if_node = IfNode(condition=tokens_by_line[1:],
|
|
63
69
|
body=[]) # on crée la node avec les arguments de condition du if
|
|
64
70
|
last_block.body.append(if_node)
|
|
@@ -81,6 +87,8 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
81
87
|
elif first_token_line.value == 'elif':
|
|
82
88
|
if not isinstance(last_block, (IfNode, ElifNode)):
|
|
83
89
|
raise SyntaxError(f'[ELIF] No conditional bloc open on line {first_token_line.position} !')
|
|
90
|
+
if len(tokens_by_line) <= 1:
|
|
91
|
+
raise SyntaxError(f'[ELIF] Take one or more arguments on line {first_token_line.position} !')
|
|
84
92
|
elif_node = ElifNode(condition=tokens_by_line[1:], body=[],
|
|
85
93
|
parent=last_block if isinstance(last_block, IfNode) else last_block.parent)
|
|
86
94
|
|
|
@@ -91,7 +99,6 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
91
99
|
last_block.elif_nodes = [elif_node]
|
|
92
100
|
else:
|
|
93
101
|
last_block.elif_nodes.append(elif_node)
|
|
94
|
-
|
|
95
102
|
blocks.append(elif_node)
|
|
96
103
|
|
|
97
104
|
elif first_token_line.value == 'else':
|
|
@@ -102,7 +109,6 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
102
109
|
raise SyntaxError(f'[ELSE] already define !')
|
|
103
110
|
|
|
104
111
|
else_node = ElseNode(body=[])
|
|
105
|
-
|
|
106
112
|
if isinstance(last_block, ElifNode): # si le dernier bloc est un elif
|
|
107
113
|
last_block.parent.else_body = else_node # on ajoute le bloc else à son parent (qui est le dernier if)
|
|
108
114
|
else:
|
|
@@ -110,6 +116,15 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
110
116
|
blocks.append(else_node)
|
|
111
117
|
|
|
112
118
|
elif first_token_line.value == 'loop':
|
|
119
|
+
if len(tokens_by_line) <= 2:
|
|
120
|
+
raise SyntaxError(f'[LOOP] Take two arguments on line {first_token_line.position} !')
|
|
121
|
+
if tokens_by_line[1].type != DTT.IDENT:
|
|
122
|
+
raise TypeError(f'[LOOP] the variable given must be a ident, '
|
|
123
|
+
f'not {tokens_by_line[1].type} in line {tokens_by_line[1].position}')
|
|
124
|
+
if tokens_by_line[2].type not in (DTT.IDENT, DTT.STR, DTT.INT, DTT.FLOAT, DTT.LIST):
|
|
125
|
+
raise TypeError(f'[LOOP] the iterator must be a ident, string, integer, float or list, '
|
|
126
|
+
f'not {tokens_by_line[2].type} in line {tokens_by_line[2].position}')
|
|
127
|
+
|
|
113
128
|
loop_node = LoopNode(VarNode(tokens_by_line[1], to_postfix(tokens_by_line[2:])), body=[])
|
|
114
129
|
last_block.body.append(loop_node)
|
|
115
130
|
_, p = parse(token_lines[pointeur + 1:],
|
|
@@ -119,11 +134,18 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
119
134
|
elif first_token_line.value == '#loop': # si rencontré
|
|
120
135
|
if not isinstance(last_block, LoopNode):
|
|
121
136
|
raise SyntaxError(f'[#LOOP] No loop open on line {first_token_line.position} !')
|
|
137
|
+
|
|
122
138
|
blocks.pop()
|
|
123
139
|
return blocks, pointeur # on renvoie les informations parsé à la dernière loop ouverte
|
|
124
140
|
|
|
125
141
|
elif first_token_line.value == 'var':
|
|
126
|
-
|
|
142
|
+
if len(tokens_by_line) <= 2:
|
|
143
|
+
raise SyntaxError(f'[VAR] Take two arguments on line {first_token_line.position} !')
|
|
144
|
+
if tokens_by_line[1].type != DTT.IDENT:
|
|
145
|
+
raise TypeError(f'[VAR] the variable given must be a ident, '
|
|
146
|
+
f'not {tokens_by_line[1].type} in line {tokens_by_line[1].position}')
|
|
147
|
+
|
|
148
|
+
var_node = VarNode(name=tokens_by_line[1], body=[])
|
|
127
149
|
last_block.body.append(var_node)
|
|
128
150
|
result, status = parser_inline(tokens_by_line[
|
|
129
151
|
2:]) # on fait en sorte de mettre les tokens de la ligne séparé par des retour à la ligne à chaque condition/else
|
|
@@ -134,10 +156,22 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
134
156
|
var_node.body = result[0]
|
|
135
157
|
|
|
136
158
|
elif first_token_line.value == 'sleep':
|
|
159
|
+
if len(tokens_by_line) <= 1:
|
|
160
|
+
raise SyntaxError(f'[SLEEP] Take one arguments on line {first_token_line.position} !')
|
|
161
|
+
if tokens_by_line[1].type != DTT.INT:
|
|
162
|
+
raise TypeError(f'[SLEEP] the variable given must be an integer, '
|
|
163
|
+
f'not {tokens_by_line[1].type} in line {tokens_by_line[1].position}')
|
|
164
|
+
|
|
137
165
|
sleep_node = SleepNode(tokens_by_line[1:])
|
|
138
166
|
last_block.body.append(sleep_node)
|
|
139
167
|
|
|
140
168
|
elif first_token_line.value == 'param':
|
|
169
|
+
if len(tokens_by_line) <= 1:
|
|
170
|
+
raise SyntaxError(f'[PARAM] Take one arguments on line {first_token_line.position} !')
|
|
171
|
+
if tokens_by_line[1].type != DTT.IDENT:
|
|
172
|
+
raise TypeError(f'[PARAM] the variable given must be a ident, '
|
|
173
|
+
f'not {tokens_by_line[1].type} in line {tokens_by_line[1].position}')
|
|
174
|
+
|
|
141
175
|
param_node = ParamNode(body=[])
|
|
142
176
|
last_block.body.append(param_node)
|
|
143
177
|
_, p = parse(token_lines[pointeur + 1:], param_node)
|
|
@@ -146,6 +180,7 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
146
180
|
elif first_token_line.value == '#param':
|
|
147
181
|
if not isinstance(last_block, ParamNode):
|
|
148
182
|
raise SyntaxError(f'[#PARAM] No parameters open on line {first_token_line.position} !')
|
|
183
|
+
|
|
149
184
|
blocks.pop() # on supprime le dernier bloc (le paramètre)
|
|
150
185
|
return blocks, pointeur # on renvoie les informations parsé à la dernière paramètre ouverte
|
|
151
186
|
|
|
@@ -153,11 +188,26 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
153
188
|
end_node = EndNode()
|
|
154
189
|
last_block.body.append(end_node)
|
|
155
190
|
|
|
191
|
+
elif first_token_line.value in ('length', 'len'):
|
|
192
|
+
if len(tokens_by_line) != 2:
|
|
193
|
+
raise SyntaxError(f"[LENGTH] Take 2 arguments on line {first_token_line.position} !")
|
|
194
|
+
if first_token_line.type not in (DTT.IDENT, DTT.STR, DTT.LIST):
|
|
195
|
+
raise SyntaxError(f"[LENGTH] Take an ident, str or list on line {first_token_line.position}, not {first_token_line.type} !")
|
|
196
|
+
|
|
197
|
+
var_node = VarNode(tokens_by_line[1], body=[LengthNode(tokens_by_line[2])])
|
|
198
|
+
last_block.body.append(var_node)
|
|
199
|
+
|
|
156
200
|
############################## DISCORD KEYWORDS ##############################
|
|
157
201
|
|
|
158
202
|
elif first_token_line.type == DTT.DISCORD_KEYWORD:
|
|
159
203
|
|
|
160
204
|
if first_token_line.value == 'embed':
|
|
205
|
+
if len(tokens_by_line) <= 1:
|
|
206
|
+
raise SyntaxError(f'[EMBED] Take one or more arguments on line {first_token_line.position} !')
|
|
207
|
+
if tokens_by_line[1].type != DTT.IDENT:
|
|
208
|
+
raise TypeError(f'[EMBED] the variable given must be a ident, '
|
|
209
|
+
f'not {tokens_by_line[1].type} in line {tokens_by_line[1].position}')
|
|
210
|
+
|
|
161
211
|
embed_node = EmbedNode(body=[], fields=[])
|
|
162
212
|
var_node = VarNode(tokens_by_line[1], body=[embed_node])
|
|
163
213
|
last_block.body.append(var_node)
|
|
@@ -171,11 +221,20 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
171
221
|
return blocks, pointeur
|
|
172
222
|
|
|
173
223
|
elif first_token_line.value == 'field':
|
|
224
|
+
if len(tokens_by_line) <= 1:
|
|
225
|
+
raise SyntaxError(f'[FIELD] Take one or more arguments on line {first_token_line.position} !')
|
|
174
226
|
if not isinstance(last_block, EmbedNode):
|
|
175
227
|
raise SyntaxError(f'[FIELD] No embed open on line {first_token_line.position} !')
|
|
228
|
+
|
|
176
229
|
last_block.fields.append(FieldEmbedNode(tokens_by_line[1:]))
|
|
177
230
|
|
|
178
231
|
elif first_token_line.value in ('perm', 'permission'):
|
|
232
|
+
if len(tokens_by_line) <= 1:
|
|
233
|
+
raise SyntaxError(f'[PERM] Take one argument on line {first_token_line.position} !')
|
|
234
|
+
if tokens_by_line[1].type != DTT.IDENT:
|
|
235
|
+
raise TypeError(f'[PERM] the variable given must be a ident, '
|
|
236
|
+
f'not {tokens_by_line[1].type} in line {tokens_by_line[1].position}')
|
|
237
|
+
|
|
179
238
|
perm_node = PermissionNode(body=[])
|
|
180
239
|
var_node = VarNode(tokens_by_line[1], body=[perm_node])
|
|
181
240
|
last_block.body.append(var_node)
|
|
@@ -189,6 +248,12 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
189
248
|
return blocks, pointeur
|
|
190
249
|
|
|
191
250
|
elif first_token_line.value == 'ui':
|
|
251
|
+
if len(tokens_by_line) <= 1:
|
|
252
|
+
raise SyntaxError(f'[UI] Take one argument on line {first_token_line.position} !')
|
|
253
|
+
if tokens_by_line[1].type != DTT.IDENT:
|
|
254
|
+
raise TypeError(f'[UI] the variable given must be a ident, '
|
|
255
|
+
f'not {tokens_by_line[1].type} in line {tokens_by_line[1].position}')
|
|
256
|
+
|
|
192
257
|
ui_node = UiNode([])
|
|
193
258
|
var_node = VarNode(tokens_by_line[1], body=[ui_node])
|
|
194
259
|
last_block.body.append(var_node)
|
|
@@ -202,12 +267,17 @@ def parse(token_lines: list[list[Token]], start_node: ASTNode) -> tuple[list[AST
|
|
|
202
267
|
return blocks, pointeur
|
|
203
268
|
|
|
204
269
|
elif first_token_line.value == 'button':
|
|
270
|
+
if len(tokens_by_line) <= 1:
|
|
271
|
+
raise SyntaxError(f'[BUTTON] Take one or more arguments on line {first_token_line.position} !')
|
|
205
272
|
if not isinstance(last_block, UiNode):
|
|
206
273
|
raise SyntaxError(f'[BUTTON] No UI open on line {first_token_line.position} !')
|
|
274
|
+
|
|
207
275
|
button_node = UiButtonNode(tokens_by_line[1:])
|
|
208
276
|
last_block.buttons.append(button_node)
|
|
209
277
|
|
|
210
278
|
elif first_token_line.value == 'select':
|
|
279
|
+
if len(tokens_by_line) <= 1:
|
|
280
|
+
raise SyntaxError(f'[SELECT] Take one or more arguments on line {first_token_line.position} !')
|
|
211
281
|
if not isinstance(last_block, UiNode):
|
|
212
282
|
raise SyntaxError(f'[SELECT] No UI open on line {first_token_line.position} !')
|
|
213
283
|
select_node = UiSelectNode(tokens_by_line[1:])
|
|
@@ -18,7 +18,7 @@ from ..DISCORD_COMMANDS.dshell_role import *
|
|
|
18
18
|
from ..DISCORD_COMMANDS.dshell_interaction import *
|
|
19
19
|
|
|
20
20
|
dshell_keyword: set[str] = {
|
|
21
|
-
'if', 'else', 'elif', 'loop', '#end', 'var', '#loop', '#if', 'sleep', 'param', '#param'
|
|
21
|
+
'if', 'else', 'elif', 'loop', '#end', 'var', '#loop', '#if', 'sleep', 'param', '#param', 'length', 'len'
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
dshell_discord_keyword: set[str] = {
|
|
@@ -36,7 +36,7 @@ dshell_commands: dict[str, Callable] = {
|
|
|
36
36
|
"em": dshell_edit_message, # edit message
|
|
37
37
|
|
|
38
38
|
"sri": dshell_respond_interaction, # respond to an interaction
|
|
39
|
-
"
|
|
39
|
+
"sdi": dshell_defer_interaction, # defer an interaction
|
|
40
40
|
|
|
41
41
|
"cc": dshell_create_text_channel, # create channel
|
|
42
42
|
"cvc": dshell_create_voice_channel, # create voice channel
|
|
@@ -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.17",
|
|
9
9
|
author="Chronos",
|
|
10
10
|
author_email="vagabonwalybi@gmail.com",
|
|
11
11
|
description="A Discord bot interpreter for creating custom commands and automations.",
|
{dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/DISCORD_COMMANDS/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/DISCORD_COMMANDS/dshell_member.py
RENAMED
|
File without changes
|
|
File without changes
|
{dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/DISCORD_COMMANDS/dshell_role.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/_DshellInterpreteur/__init__.py
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/Dshell/_DshellParser/__init__.py
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/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.15 → dshellinterpreter-0.2.13.17}/dshellInterpreter.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/dshellInterpreter.egg-info/requires.txt
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.15 → dshellinterpreter-0.2.13.17}/dshellInterpreter.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|