dshellInterpreter 0.2.5.3__py3-none-any.whl → 0.2.7__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_message.py +35 -2
- Dshell/_DshellInterpreteur/dshell_interpreter.py +8 -2
- Dshell/_DshellParser/dshell_parser.py +2 -2
- Dshell/_DshellTokenizer/dshell_keywords.py +11 -9
- {dshellinterpreter-0.2.5.3.dist-info → dshellinterpreter-0.2.7.dist-info}/METADATA +1 -1
- {dshellinterpreter-0.2.5.3.dist-info → dshellinterpreter-0.2.7.dist-info}/RECORD +9 -9
- {dshellinterpreter-0.2.5.3.dist-info → dshellinterpreter-0.2.7.dist-info}/WHEEL +0 -0
- {dshellinterpreter-0.2.5.3.dist-info → dshellinterpreter-0.2.7.dist-info}/licenses/LICENSE +0 -0
- {dshellinterpreter-0.2.5.3.dist-info → dshellinterpreter-0.2.7.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from re import search
|
|
2
2
|
|
|
3
|
-
from discord import Embed, Message
|
|
3
|
+
from discord import Embed, Message, NotFound
|
|
4
4
|
from discord.ext import commands
|
|
5
5
|
|
|
6
6
|
__all__ = [
|
|
@@ -11,7 +11,9 @@ __all__ = [
|
|
|
11
11
|
'dshell_get_hystory_messages',
|
|
12
12
|
'dshell_research_regex_in_content',
|
|
13
13
|
'dshell_add_reactions',
|
|
14
|
-
'dshell_remove_reactions'
|
|
14
|
+
'dshell_remove_reactions',
|
|
15
|
+
'dshell_clear_message_reactions',
|
|
16
|
+
'dshell_clear_one_reactions'
|
|
15
17
|
]
|
|
16
18
|
|
|
17
19
|
|
|
@@ -165,3 +167,34 @@ async def dshell_remove_reactions(ctx: Message, reactions, message=None):
|
|
|
165
167
|
await message.clear_reaction(reaction)
|
|
166
168
|
|
|
167
169
|
return message.id
|
|
170
|
+
|
|
171
|
+
async def dshell_clear_message_reactions(ctx: Message, message):
|
|
172
|
+
"""
|
|
173
|
+
Clear all reaction on the target message
|
|
174
|
+
"""
|
|
175
|
+
if not isinstance(message, int):
|
|
176
|
+
raise Exception(f'Message must be integer, not {type(message)}')
|
|
177
|
+
|
|
178
|
+
target_message = await ctx.channel.fetch_message(message)
|
|
179
|
+
|
|
180
|
+
if target_message is None:
|
|
181
|
+
raise Exception(f'Message not found !')
|
|
182
|
+
|
|
183
|
+
await target_message.clear_reactions()
|
|
184
|
+
|
|
185
|
+
async def dshell_clear_one_reactions(ctx: Message, message, emoji):
|
|
186
|
+
"""
|
|
187
|
+
Clear one emoji on the target message
|
|
188
|
+
"""
|
|
189
|
+
if not isinstance(message, int):
|
|
190
|
+
raise Exception(f'Message must be integer, not {type(message)}')
|
|
191
|
+
|
|
192
|
+
if not isinstance(emoji, str):
|
|
193
|
+
raise Exception(f'Emoji must be string, not {type(emoji)}')
|
|
194
|
+
|
|
195
|
+
try:
|
|
196
|
+
target_message = await ctx.channel.fetch_message(message)
|
|
197
|
+
except NotFound:
|
|
198
|
+
raise Exception(f'Message not found !')
|
|
199
|
+
|
|
200
|
+
await target_message.clear_reaction(emoji)
|
|
@@ -42,7 +42,6 @@ class DshellInterpreteur:
|
|
|
42
42
|
'__author_discriminator__': ctx.author.discriminator,
|
|
43
43
|
'__author_bot__': ctx.author.bot,
|
|
44
44
|
'__author_nick__': ctx.author.nick if hasattr(ctx.author, 'nick') else None,
|
|
45
|
-
'__author_avatar_url__': ctx.author.avatar.url if ctx.author.avatar else None,
|
|
46
45
|
'__author_id__': ctx.author.id,
|
|
47
46
|
'__message__': ctx.content,
|
|
48
47
|
'__message_id__': ctx.id,
|
|
@@ -259,7 +258,14 @@ def eval_expression(tokens: list[Token], interpreter: DshellInterpreteur) -> Any
|
|
|
259
258
|
|
|
260
259
|
else:
|
|
261
260
|
b = stack.pop()
|
|
262
|
-
|
|
261
|
+
try:
|
|
262
|
+
a = stack.pop()
|
|
263
|
+
except IndexError:
|
|
264
|
+
if op == "-":
|
|
265
|
+
a = 0
|
|
266
|
+
else:
|
|
267
|
+
raise SyntaxError(f"Invalid expression: {op} operator requires two operands, but only one was found.")
|
|
268
|
+
|
|
263
269
|
result = dshell_operators[op][0](a, b)
|
|
264
270
|
|
|
265
271
|
stack.append(result)
|
|
@@ -268,7 +268,7 @@ def to_postfix(expression):
|
|
|
268
268
|
operators: list[Token] = []
|
|
269
269
|
|
|
270
270
|
for token in expression:
|
|
271
|
-
if token.type in (DTT.IDENT, DTT.CALL_ARGS, DTT.INT, DTT.FLOAT, DTT.LIST, DTT.STR): # Si c'est un ident
|
|
271
|
+
if token.type in (DTT.IDENT, DTT.CALL_ARGS, DTT.INT, DTT.FLOAT, DTT.LIST, DTT.STR, DTT.BOOL): # Si c'est un ident
|
|
272
272
|
output.append(token)
|
|
273
273
|
elif token.value in dshell_operators:
|
|
274
274
|
while (operators and operators[-1].value in dshell_operators and
|
|
@@ -289,7 +289,7 @@ def parse_postfix_expression(postfix_tokens: list[Token]) -> list[IdentOperation
|
|
|
289
289
|
|
|
290
290
|
for tok in postfix_tokens:
|
|
291
291
|
|
|
292
|
-
if tok.type in (DTT.IDENT, DTT.CALL_ARGS, DTT.INT, DTT.STR, DTT.LIST):
|
|
292
|
+
if tok.type in (DTT.IDENT, DTT.CALL_ARGS, DTT.INT, DTT.STR, DTT.LIST, DTT.FLOAT, DTT.BOOL):
|
|
293
293
|
stack.append(tok)
|
|
294
294
|
|
|
295
295
|
elif tok.type == DTT.MATHS_OPERATOR:
|
|
@@ -58,19 +58,12 @@ dshell_commands: dict[str, Callable] = {
|
|
|
58
58
|
|
|
59
59
|
"ar": dshell_add_reactions, # add reactions to a message
|
|
60
60
|
"rr": dshell_remove_reactions, # remove reactions from a message
|
|
61
|
+
"cmr": dshell_clear_message_reactions,
|
|
62
|
+
"cor": dshell_clear_one_reactions
|
|
61
63
|
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
dshell_mathematical_operators: dict[str, tuple[Callable, int]] = {
|
|
65
|
-
r"<": (lambda a, b: a < b, 4),
|
|
66
|
-
r"<=": (lambda a, b: a <= b, 4),
|
|
67
|
-
r"=<": (lambda a, b: a <= b, 4),
|
|
68
|
-
r"=": (lambda a, b: a == b, 4),
|
|
69
|
-
r"!=": (lambda a, b: a != b, 4),
|
|
70
|
-
r"=!": (lambda a, b: a != b, 4),
|
|
71
|
-
r">": (lambda a, b: a > b, 4),
|
|
72
|
-
r">=": (lambda a, b: a >= b, 4),
|
|
73
|
-
r"=>": (lambda a, b: a >= b, 4),
|
|
74
67
|
|
|
75
68
|
r".": (lambda a, b: a.b, 9),
|
|
76
69
|
r"->": (lambda a: a.at, 10), # equivalent to calling .at(key)
|
|
@@ -87,6 +80,15 @@ dshell_mathematical_operators: dict[str, tuple[Callable, int]] = {
|
|
|
87
80
|
|
|
88
81
|
dshell_logical_operators: dict[str, tuple[Callable, int]] = {
|
|
89
82
|
|
|
83
|
+
r"<": (lambda a, b: a < b, 4),
|
|
84
|
+
r"<=": (lambda a, b: a <= b, 4),
|
|
85
|
+
r"=<": (lambda a, b: a <= b, 4),
|
|
86
|
+
r"=": (lambda a, b: a == b, 4),
|
|
87
|
+
r"!=": (lambda a, b: a != b, 4),
|
|
88
|
+
r"=!": (lambda a, b: a != b, 4),
|
|
89
|
+
r">": (lambda a, b: a > b, 4),
|
|
90
|
+
r">=": (lambda a, b: a >= b, 4),
|
|
91
|
+
r"=>": (lambda a, b: a >= b, 4),
|
|
90
92
|
r"and": (lambda a, b: bool(a and b), 2),
|
|
91
93
|
r"&": (lambda a, b: a & b, 2),
|
|
92
94
|
r"or": (lambda a, b: bool(a or b), 1),
|
|
@@ -3,20 +3,20 @@ Dshell/_utils.py,sha256=PJ3fwn8IMqUMnW9oTwfr9v4--rzHIhhLQoVVqjwjoJU,23
|
|
|
3
3
|
Dshell/DISCORD_COMMANDS/__init__.py,sha256=_oo_aMEju4gZg-MIbF8bKMVM6CWAF0AO9DxAlemaXMw,149
|
|
4
4
|
Dshell/DISCORD_COMMANDS/dshell_channel.py,sha256=2qnbI2tUu5sowJVOVkY4p-l6Gu-5Gw9BEP3MItScvV8,8939
|
|
5
5
|
Dshell/DISCORD_COMMANDS/dshell_member.py,sha256=L3Ud4nza_55n9R02kfL-iNK9ybBczx6SDkccUTWxv3s,7646
|
|
6
|
-
Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=
|
|
6
|
+
Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=SvX9I4nYMWm8ACE56QJBM5yEiZoXIKbTLkIOyrENd5o,6253
|
|
7
7
|
Dshell/DISCORD_COMMANDS/dshell_pastbin.py,sha256=TkWFGRRTvhhJgvwkDFx9Fz4UM2UUFwxyq0laMVx0mUk,881
|
|
8
8
|
Dshell/DISCORD_COMMANDS/dshell_role.py,sha256=fotsYWGHebgIx157q-zRbcCd90Y7jIuKCZ8udQoEzSU,4970
|
|
9
9
|
Dshell/_DshellInterpreteur/__init__.py,sha256=xy5-J-R3YmY99JF3NBHTRRLsComFxpjnCA5xacISctU,35
|
|
10
|
-
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=
|
|
10
|
+
Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=yFKK8n0hTP6hN1AexUyYsZwUBFG6Rz4UgSnCEyVJ-xw,22998
|
|
11
11
|
Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZxC4,56
|
|
12
12
|
Dshell/_DshellParser/ast_nodes.py,sha256=2qwL_M0ELPia6L6gqwgV5hqprvyuo97cx3Zk2dVz09U,15341
|
|
13
|
-
Dshell/_DshellParser/dshell_parser.py,sha256=
|
|
13
|
+
Dshell/_DshellParser/dshell_parser.py,sha256=RxS5GgmTel10pH9HII0X_8XZnVyIQGd9ThZZcZDpEqc,15545
|
|
14
14
|
Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8qrJWw_s,172
|
|
15
|
-
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=
|
|
15
|
+
Dshell/_DshellTokenizer/dshell_keywords.py,sha256=q6Mi7Y_45YJ_0XdBOZTdUAk0ZTjvr3dMwTuD-2YyQbs,4891
|
|
16
16
|
Dshell/_DshellTokenizer/dshell_token_type.py,sha256=pWzvmj6EFGkDwNHooOAjdyysi1vZRVEostFIZSW1Ais,1483
|
|
17
17
|
Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=-EhwrfbcOcnAxOHWBE89531t25u6c6HmJuT1AKFn9Ew,7032
|
|
18
|
-
dshellinterpreter-0.2.
|
|
19
|
-
dshellinterpreter-0.2.
|
|
20
|
-
dshellinterpreter-0.2.
|
|
21
|
-
dshellinterpreter-0.2.
|
|
22
|
-
dshellinterpreter-0.2.
|
|
18
|
+
dshellinterpreter-0.2.7.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
|
|
19
|
+
dshellinterpreter-0.2.7.dist-info/METADATA,sha256=LARUNA64iPo4c79uHLyrbkgOTjY1d7qLaknadneM9xQ,1120
|
|
20
|
+
dshellinterpreter-0.2.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
21
|
+
dshellinterpreter-0.2.7.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
|
|
22
|
+
dshellinterpreter-0.2.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|