dshellInterpreter 0.2.13.9__tar.gz → 0.2.13.11__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.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/dshell_message.py +49 -8
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/_DshellInterpreteur/dshell_interpreter.py +19 -18
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/_DshellTokenizer/dshell_keywords.py +1 -0
- {dshellinterpreter-0.2.13.9/dshellInterpreter.egg-info → dshellinterpreter-0.2.13.11}/PKG-INFO +1 -1
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11/dshellInterpreter.egg-info}/PKG-INFO +1 -1
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/setup.py +1 -1
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/__init__.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/dshell_channel.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/dshell_member.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/dshell_pastbin.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/dshell_role.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/utils/__init__.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/utils/utils_message.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/utils/utils_thread.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/_DshellInterpreteur/__init__.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/_DshellParser/__init__.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/_DshellParser/ast_nodes.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/_DshellParser/dshell_parser.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/_DshellTokenizer/__init__.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/_DshellTokenizer/dshell_token_type.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/_DshellTokenizer/dshell_tokenizer.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/__init__.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/_utils.py +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/LICENSE +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/README.md +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/dshellInterpreter.egg-info/SOURCES.txt +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/dshellInterpreter.egg-info/dependency_links.txt +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/dshellInterpreter.egg-info/requires.txt +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/dshellInterpreter.egg-info/top_level.txt +0 -0
- {dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/setup.cfg +0 -0
{dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/dshell_message.py
RENAMED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
from re import search
|
|
2
2
|
|
|
3
|
-
from discord import Embed, Message
|
|
3
|
+
from discord import Embed, Message, Interaction
|
|
4
4
|
from discord.ext import commands
|
|
5
|
-
from discord.abc import Messageable
|
|
6
5
|
|
|
7
6
|
from pycordViews import EasyModifiedViews
|
|
8
7
|
|
|
@@ -12,6 +11,7 @@ from .._utils import NoneType
|
|
|
12
11
|
__all__ = [
|
|
13
12
|
'dshell_send_message',
|
|
14
13
|
'dshell_respond_message',
|
|
14
|
+
'dshell_respond_interaction',
|
|
15
15
|
'dshell_delete_message',
|
|
16
16
|
'dshell_purge_message',
|
|
17
17
|
'dshell_edit_message',
|
|
@@ -42,7 +42,10 @@ async def dshell_send_message(ctx: Message, message=None, delete=None, channel=N
|
|
|
42
42
|
if not isinstance(embeds, (ListNode, Embed, NoneType)):
|
|
43
43
|
raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
|
|
44
44
|
|
|
45
|
-
if
|
|
45
|
+
if embeds is None:
|
|
46
|
+
embeds = ListNode([])
|
|
47
|
+
|
|
48
|
+
elif isinstance(embeds, Embed):
|
|
46
49
|
embeds = ListNode([embeds])
|
|
47
50
|
|
|
48
51
|
if not isinstance(view, (EasyModifiedViews, NoneType)):
|
|
@@ -68,15 +71,15 @@ async def dshell_respond_message(ctx: Message, message=None, content: str = None
|
|
|
68
71
|
|
|
69
72
|
from .._DshellParser.ast_nodes import ListNode
|
|
70
73
|
|
|
74
|
+
if not isinstance(embeds, (ListNode, Embed, NoneType)):
|
|
75
|
+
raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
|
|
76
|
+
|
|
71
77
|
if embeds is None:
|
|
72
78
|
embeds = ListNode([])
|
|
73
79
|
|
|
74
80
|
elif isinstance(embeds, Embed):
|
|
75
81
|
embeds = ListNode([embeds])
|
|
76
82
|
|
|
77
|
-
else:
|
|
78
|
-
raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
|
|
79
|
-
|
|
80
83
|
sended_message = await respond_message.reply(
|
|
81
84
|
content=str(content),
|
|
82
85
|
mention_author=mention_author,
|
|
@@ -85,6 +88,39 @@ async def dshell_respond_message(ctx: Message, message=None, content: str = None
|
|
|
85
88
|
|
|
86
89
|
return sended_message.id
|
|
87
90
|
|
|
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
|
+
|
|
88
124
|
async def dshell_delete_message(ctx: Message, message=None, reason=None, delay=0):
|
|
89
125
|
"""
|
|
90
126
|
Deletes a message
|
|
@@ -123,11 +159,16 @@ async def dshell_edit_message(ctx: Message, message, new_content=None, embeds=No
|
|
|
123
159
|
"""
|
|
124
160
|
edit_message = utils_get_message(ctx, message)
|
|
125
161
|
|
|
162
|
+
from .._DshellParser.ast_nodes import ListNode
|
|
163
|
+
|
|
164
|
+
if not isinstance(embeds, (ListNode, Embed, NoneType)):
|
|
165
|
+
raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
|
|
166
|
+
|
|
126
167
|
if embeds is None:
|
|
127
|
-
embeds = []
|
|
168
|
+
embeds = ListNode([])
|
|
128
169
|
|
|
129
170
|
elif isinstance(embeds, Embed):
|
|
130
|
-
embeds = [embeds]
|
|
171
|
+
embeds = ListNode([embeds])
|
|
131
172
|
|
|
132
173
|
await edit_message.edit(content=new_content, embeds=embeds)
|
|
133
174
|
|
|
@@ -19,7 +19,7 @@ from .._DshellTokenizer.dshell_token_type import Token
|
|
|
19
19
|
from .._DshellTokenizer.dshell_tokenizer import DshellTokenizer
|
|
20
20
|
|
|
21
21
|
All_nodes = TypeVar('All_nodes', IfNode, LoopNode, ElseNode, ElifNode, ArgsCommandNode, VarNode, IdentOperationNode)
|
|
22
|
-
context = TypeVar('context', AutoShardedBot, Message, PrivateChannel)
|
|
22
|
+
context = TypeVar('context', AutoShardedBot, Message, PrivateChannel, Interaction)
|
|
23
23
|
ButtonStyleValues: tuple = tuple(i.name for i in ButtonStyle)
|
|
24
24
|
|
|
25
25
|
class DshellInterpreteur:
|
|
@@ -37,24 +37,25 @@ class DshellInterpreteur:
|
|
|
37
37
|
:param vars: Optional dictionary of variables to initialize in the interpreter's environment.
|
|
38
38
|
"""
|
|
39
39
|
self.ast: list[ASTNode] = parse(DshellTokenizer(code).start(), StartNode([]))[0]
|
|
40
|
+
message = ctx.message if isinstance(ctx, Interaction) else ctx
|
|
40
41
|
self.env: dict[str, Any] = {
|
|
41
42
|
'__ret__': None, # environment variables, '__ret__' is used to store the return value of commands
|
|
42
|
-
'__guild__':
|
|
43
|
-
'__channel__':
|
|
44
|
-
'__author__':
|
|
45
|
-
'__author_display_name__':
|
|
46
|
-
'__author_avatar__':
|
|
47
|
-
'__author_discriminator__':
|
|
48
|
-
'__author_bot__':
|
|
49
|
-
'__author_nick__':
|
|
50
|
-
'__author_id__':
|
|
51
|
-
'__message__':
|
|
52
|
-
'__message_id__':
|
|
53
|
-
'__channel_name__':
|
|
54
|
-
'__channel_type__':
|
|
55
|
-
'__channel_id__':
|
|
56
|
-
'__private_channel__': isinstance(
|
|
57
|
-
} if
|
|
43
|
+
'__guild__': message.channel.guild.name,
|
|
44
|
+
'__channel__': message.channel.name,
|
|
45
|
+
'__author__': message.author.name,
|
|
46
|
+
'__author_display_name__': message.author.display_name,
|
|
47
|
+
'__author_avatar__': message.author.display_avatar.url if message.author.display_avatar else None,
|
|
48
|
+
'__author_discriminator__': message.author.discriminator,
|
|
49
|
+
'__author_bot__': message.author.bot,
|
|
50
|
+
'__author_nick__': message.author.nick if hasattr(message.author, 'nick') else None,
|
|
51
|
+
'__author_id__': message.author.id,
|
|
52
|
+
'__message__': message.content,
|
|
53
|
+
'__message_id__': message.id,
|
|
54
|
+
'__channel_name__': message.channel.name,
|
|
55
|
+
'__channel_type__': message.channel.type.name if hasattr(message.channel, 'type') else None,
|
|
56
|
+
'__channel_id__': message.channel.id,
|
|
57
|
+
'__private_channel__': isinstance(message.channel, PrivateChannel),
|
|
58
|
+
} if message is not None else {}
|
|
58
59
|
self.vars = vars if vars is not None else ''
|
|
59
60
|
self.ctx: context = ctx
|
|
60
61
|
if debug:
|
|
@@ -473,7 +474,7 @@ async def ui_button_callback(button: Button, interaction: Interaction, data: dic
|
|
|
473
474
|
'__private_channel__': isinstance(interaction.channel, PrivateChannel),
|
|
474
475
|
}
|
|
475
476
|
local_env.update(data)
|
|
476
|
-
x = DshellInterpreteur(code, interaction
|
|
477
|
+
x = DshellInterpreteur(code, interaction, debug=False)
|
|
477
478
|
x.env.update(local_env)
|
|
478
479
|
await x.execute()
|
|
479
480
|
else:
|
|
@@ -30,6 +30,7 @@ dshell_commands: dict[str, Callable] = {
|
|
|
30
30
|
"sm": dshell_send_message, # send message
|
|
31
31
|
"spm": dshell_send_private_message, # send private message
|
|
32
32
|
"srm": dshell_respond_message, # respond to a message
|
|
33
|
+
"sri": dshell_respond_interaction, # respond to an interaction
|
|
33
34
|
"dm": dshell_delete_message,
|
|
34
35
|
"pm": dshell_purge_message,
|
|
35
36
|
"em": dshell_edit_message, # edit message
|
|
@@ -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.11",
|
|
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.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/__init__.py
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/dshell_channel.py
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/dshell_member.py
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/dshell_pastbin.py
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/dshell_role.py
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/DISCORD_COMMANDS/utils/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/_DshellInterpreteur/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/_DshellParser/ast_nodes.py
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/Dshell/_DshellParser/dshell_parser.py
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/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.9 → dshellinterpreter-0.2.13.11}/dshellInterpreter.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/dshellInterpreter.egg-info/requires.txt
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.13.9 → dshellinterpreter-0.2.13.11}/dshellInterpreter.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|