dshellInterpreter 0.2.9__tar.gz → 0.2.9.2__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.9 → dshellinterpreter-0.2.9.2}/Dshell/DISCORD_COMMANDS/dshell_channel.py +5 -57
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/DISCORD_COMMANDS/dshell_member.py +31 -1
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/DISCORD_COMMANDS/dshell_message.py +41 -21
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/DISCORD_COMMANDS/dshell_role.py +2 -1
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/_DshellTokenizer/dshell_keywords.py +2 -0
- {dshellinterpreter-0.2.9/dshellInterpreter.egg-info → dshellinterpreter-0.2.9.2}/PKG-INFO +1 -1
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2/dshellInterpreter.egg-info}/PKG-INFO +1 -1
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/setup.py +1 -1
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/DISCORD_COMMANDS/__init__.py +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/DISCORD_COMMANDS/dshell_pastbin.py +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/_DshellInterpreteur/__init__.py +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/_DshellInterpreteur/dshell_interpreter.py +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/_DshellParser/__init__.py +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/_DshellParser/ast_nodes.py +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/_DshellParser/dshell_parser.py +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/_DshellTokenizer/__init__.py +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/_DshellTokenizer/dshell_token_type.py +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/_DshellTokenizer/dshell_tokenizer.py +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/__init__.py +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/_utils.py +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/LICENSE +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/README.md +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/dshellInterpreter.egg-info/SOURCES.txt +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/dshellInterpreter.egg-info/dependency_links.txt +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/dshellInterpreter.egg-info/requires.txt +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/dshellInterpreter.egg-info/top_level.txt +0 -0
- {dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/setup.cfg +0 -0
{dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/DISCORD_COMMANDS/dshell_channel.py
RENAMED
|
@@ -2,9 +2,11 @@ from asyncio import sleep
|
|
|
2
2
|
from re import search
|
|
3
3
|
from typing import Union
|
|
4
4
|
|
|
5
|
-
from discord import MISSING, PermissionOverwrite, Member, Role, Message
|
|
5
|
+
from discord import MISSING, PermissionOverwrite, Member, Role, Message
|
|
6
6
|
from discord.utils import _MissingSentinel
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
from .utils.utils_message import utils_get_message
|
|
9
|
+
from .utils.utils_thread import utils_get_thread
|
|
8
10
|
|
|
9
11
|
__all__ = [
|
|
10
12
|
'dshell_get_channel',
|
|
@@ -22,60 +24,6 @@ __all__ = [
|
|
|
22
24
|
'dshell_edit_thread'
|
|
23
25
|
]
|
|
24
26
|
|
|
25
|
-
async def utils_get_message(ctx: Message, message: Union[int, str]) -> Message:
|
|
26
|
-
"""
|
|
27
|
-
Returns the message object of the specified message ID or link.
|
|
28
|
-
Message is only available in the same server as the command and in the same channel.
|
|
29
|
-
If the message is a link, it must be in the format: https://discord.com/channels/{guild_id}/{channel_id}/{message_id}
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
if isinstance(message, int):
|
|
33
|
-
return await ctx.channel.fetch_message(message)
|
|
34
|
-
|
|
35
|
-
elif isinstance(message, str):
|
|
36
|
-
match = search(r'https://discord\.com/channels/(\d+)/(\d+)/(\d+)', message)
|
|
37
|
-
if not match:
|
|
38
|
-
raise Exception("Invalid message link format. Use a valid Discord message link.")
|
|
39
|
-
guild_id = int(match.group(1))
|
|
40
|
-
channel_id = int(match.group(2))
|
|
41
|
-
message_id = int(match.group(3))
|
|
42
|
-
|
|
43
|
-
if guild_id != ctx.guild.id:
|
|
44
|
-
raise Exception("The message must be from the same server as the command !")
|
|
45
|
-
|
|
46
|
-
return await ctx.guild.get_channel(channel_id).fetch_message(message_id)
|
|
47
|
-
|
|
48
|
-
raise Exception(f"Message must be an integer or a string, not {type(message)} !")
|
|
49
|
-
|
|
50
|
-
async def utils_get_thread(ctx: Message, thread: Union[int, str]) -> Thread:
|
|
51
|
-
"""
|
|
52
|
-
Returns the thread object of the specified thread ID or link.
|
|
53
|
-
Thread is only available in the same server as the command and in the same channel.
|
|
54
|
-
If the thread is a link, it must be in the format: https://discord.com/channels/{guild_id}/{channel_id}/{message_id}
|
|
55
|
-
"""
|
|
56
|
-
|
|
57
|
-
if isinstance(thread, int):
|
|
58
|
-
return ctx.channel.get_thread(thread)
|
|
59
|
-
|
|
60
|
-
elif isinstance(thread, str):
|
|
61
|
-
match = search(r'https://discord\.com/channels/(\d+)/(\d+)(/\d+)?', thread)
|
|
62
|
-
if not match:
|
|
63
|
-
raise Exception("Invalid thread link format. Use a valid Discord thread link.")
|
|
64
|
-
guild_id = int(match.group(1))
|
|
65
|
-
message_id = int(match.group(2))
|
|
66
|
-
channel_id = ctx.channel.id if len(match.groups()) == 3 else ctx.channel.id
|
|
67
|
-
|
|
68
|
-
if guild_id != ctx.guild.id:
|
|
69
|
-
raise Exception("The thread must be from the same server as the command !")
|
|
70
|
-
|
|
71
|
-
try:
|
|
72
|
-
c = await ctx.guild.get_channel(channel_id).fetch_message(message_id)
|
|
73
|
-
return c.thread
|
|
74
|
-
except NotFound:
|
|
75
|
-
raise Exception(f"Thread with ID {message_id} not found in channel {channel_id} !")
|
|
76
|
-
|
|
77
|
-
raise Exception(f"Thread must be an integer or a string, not {type(thread)} !")
|
|
78
|
-
|
|
79
27
|
|
|
80
28
|
async def dshell_get_channel(ctx: Message, name):
|
|
81
29
|
"""
|
|
@@ -338,7 +286,7 @@ async def dshell_create_thread_message(ctx: Message,
|
|
|
338
286
|
if message is None:
|
|
339
287
|
message = ctx.id
|
|
340
288
|
|
|
341
|
-
message =
|
|
289
|
+
message = utils_get_message(ctx, message)
|
|
342
290
|
|
|
343
291
|
|
|
344
292
|
if not isinstance(name, str):
|
{dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/DISCORD_COMMANDS/dshell_member.py
RENAMED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from datetime import timedelta, datetime, UTC
|
|
2
2
|
|
|
3
|
-
from discord import MISSING, Message, Member, Permissions, Role
|
|
3
|
+
from discord import MISSING, Message, Member, Permissions, Role, Embed
|
|
4
4
|
|
|
5
5
|
__all__ = [
|
|
6
|
+
"dshell_send_private_message",
|
|
6
7
|
"dshell_ban_member",
|
|
7
8
|
"dshell_unban_member",
|
|
8
9
|
"dshell_kick_member",
|
|
@@ -16,6 +17,35 @@ __all__ = [
|
|
|
16
17
|
"dshell_remove_member_roles"
|
|
17
18
|
]
|
|
18
19
|
|
|
20
|
+
async def dshell_send_private_message(ctx: Message, message: str = None, member: int = None, delete: int = None, embeds = None, ):
|
|
21
|
+
"""
|
|
22
|
+
Sends a private message to a member.
|
|
23
|
+
If member is None, sends the message to the author of the command.
|
|
24
|
+
If delete is specified, deletes the message after the specified time in seconds.
|
|
25
|
+
"""
|
|
26
|
+
if delete is not None and not isinstance(delete, (int, float)):
|
|
27
|
+
raise Exception(f'Delete parameter must be a number (seconds) or None, not {type(delete)} !')
|
|
28
|
+
|
|
29
|
+
member_to_send = ctx.author if member is None else ctx.channel.guild.get_member(member)
|
|
30
|
+
|
|
31
|
+
if member_to_send is None:
|
|
32
|
+
raise Exception(f'Member {member} not found!')
|
|
33
|
+
|
|
34
|
+
from .._DshellParser.ast_nodes import ListNode
|
|
35
|
+
|
|
36
|
+
if embeds is None:
|
|
37
|
+
embeds = ListNode([])
|
|
38
|
+
|
|
39
|
+
elif isinstance(embeds, Embed):
|
|
40
|
+
embeds = ListNode([embeds])
|
|
41
|
+
|
|
42
|
+
else:
|
|
43
|
+
raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
|
|
44
|
+
|
|
45
|
+
sended_message = await member_to_send.send(message, delete_after=delete, embeds=embeds)
|
|
46
|
+
|
|
47
|
+
return sended_message.id
|
|
48
|
+
|
|
19
49
|
|
|
20
50
|
async def dshell_ban_member(ctx: Message, member: int, reason: str = MISSING):
|
|
21
51
|
"""
|
{dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/DISCORD_COMMANDS/dshell_message.py
RENAMED
|
@@ -3,8 +3,11 @@ from re import search
|
|
|
3
3
|
from discord import Embed, Message, NotFound
|
|
4
4
|
from discord.ext import commands
|
|
5
5
|
|
|
6
|
+
from .utils.utils_message import utils_get_message
|
|
7
|
+
|
|
6
8
|
__all__ = [
|
|
7
9
|
'dshell_send_message',
|
|
10
|
+
'dshell_respond_message',
|
|
8
11
|
'dshell_delete_message',
|
|
9
12
|
'dshell_purge_message',
|
|
10
13
|
'dshell_edit_message',
|
|
@@ -47,13 +50,41 @@ async def dshell_send_message(ctx: Message, message=None, delete=None, channel=N
|
|
|
47
50
|
return sended_message.id
|
|
48
51
|
|
|
49
52
|
|
|
53
|
+
async def dshell_respond_message(ctx: Message, message=None, content: str = None, delete=None, mention: bool = None, embeds=None):
|
|
54
|
+
"""
|
|
55
|
+
Responds to a message on Discord
|
|
56
|
+
"""
|
|
57
|
+
if delete is not None and not isinstance(delete, (int, float)):
|
|
58
|
+
raise Exception(f'Delete parameter must be a number (seconds) or None, not {type(delete)} !')
|
|
59
|
+
|
|
60
|
+
respond_message = ctx if message is None else utils_get_message(ctx, message) # builds a reference to the message (even if it doesn't exist)
|
|
61
|
+
mention_author = mention if mention is not None else False
|
|
62
|
+
|
|
63
|
+
from .._DshellParser.ast_nodes import ListNode
|
|
64
|
+
|
|
65
|
+
if embeds is None:
|
|
66
|
+
embeds = ListNode([])
|
|
67
|
+
|
|
68
|
+
elif isinstance(embeds, Embed):
|
|
69
|
+
embeds = ListNode([embeds])
|
|
70
|
+
|
|
71
|
+
else:
|
|
72
|
+
raise Exception(f'Embeds must be a list of Embed objects or a single Embed object, not {type(embeds)} !')
|
|
73
|
+
|
|
74
|
+
sended_message = await ctx.reply(reference=respond_message,
|
|
75
|
+
content=content,
|
|
76
|
+
mention_author=mention_author,
|
|
77
|
+
delete_after=delete,
|
|
78
|
+
embeds=embeds)
|
|
79
|
+
|
|
80
|
+
return sended_message.id
|
|
81
|
+
|
|
50
82
|
async def dshell_delete_message(ctx: Message, message=None, reason=None, delay=0):
|
|
51
83
|
"""
|
|
52
84
|
Deletes a message
|
|
53
85
|
"""
|
|
54
86
|
|
|
55
|
-
delete_message = ctx if message is None else ctx
|
|
56
|
-
message) # builds a reference to the message (even if it doesn't exist)
|
|
87
|
+
delete_message = ctx if message is None else utils_get_message(ctx, message)
|
|
57
88
|
|
|
58
89
|
if not isinstance(delay, int):
|
|
59
90
|
raise Exception(f'Delete delay must be an integer, not {type(delay)} !')
|
|
@@ -64,7 +95,7 @@ async def dshell_delete_message(ctx: Message, message=None, reason=None, delay=0
|
|
|
64
95
|
await delete_message.delete(delay=delay, reason=reason)
|
|
65
96
|
|
|
66
97
|
|
|
67
|
-
async def dshell_purge_message(ctx: Message, message_number, channel=None, reason=None):
|
|
98
|
+
async def dshell_purge_message(ctx: Message, message_number: int, channel=None, reason=None):
|
|
68
99
|
"""
|
|
69
100
|
Purges messages from a channel
|
|
70
101
|
"""
|
|
@@ -84,8 +115,7 @@ async def dshell_edit_message(ctx: Message, message, new_content=None, embeds=No
|
|
|
84
115
|
"""
|
|
85
116
|
Edits a message
|
|
86
117
|
"""
|
|
87
|
-
edit_message = ctx
|
|
88
|
-
message) # builds a reference to the message (even if it doesn't exist)
|
|
118
|
+
edit_message = utils_get_message(ctx, message)
|
|
89
119
|
|
|
90
120
|
if embeds is None:
|
|
91
121
|
embeds = []
|
|
@@ -141,8 +171,7 @@ async def dshell_add_reactions(ctx: Message, reactions, message=None):
|
|
|
141
171
|
"""
|
|
142
172
|
Adds reactions to a message
|
|
143
173
|
"""
|
|
144
|
-
message = ctx if message is None else ctx
|
|
145
|
-
message) # builds a reference to the message (even if it doesn't exist)
|
|
174
|
+
message = ctx if message is None else utils_get_message(ctx, message)
|
|
146
175
|
|
|
147
176
|
if isinstance(reactions, str):
|
|
148
177
|
reactions = (reactions,)
|
|
@@ -157,8 +186,7 @@ async def dshell_remove_reactions(ctx: Message, reactions, message=None):
|
|
|
157
186
|
"""
|
|
158
187
|
Removes reactions from a message
|
|
159
188
|
"""
|
|
160
|
-
message = ctx if message is None else ctx
|
|
161
|
-
message) # builds a reference to the message (even if it doesn't exist)
|
|
189
|
+
message = ctx if message is None else utils_get_message(ctx, message)
|
|
162
190
|
|
|
163
191
|
if isinstance(reactions, str):
|
|
164
192
|
reactions = [reactions]
|
|
@@ -172,29 +200,21 @@ async def dshell_clear_message_reactions(ctx: Message, message):
|
|
|
172
200
|
"""
|
|
173
201
|
Clear all reaction on the target message
|
|
174
202
|
"""
|
|
175
|
-
if
|
|
176
|
-
raise Exception(f'Message must be integer, not {type(message)}')
|
|
203
|
+
message = ctx if message is None else utils_get_message(ctx, message)
|
|
177
204
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if target_message is None:
|
|
205
|
+
if message is None:
|
|
181
206
|
raise Exception(f'Message not found !')
|
|
182
207
|
|
|
183
|
-
await
|
|
208
|
+
await message.clear_reactions()
|
|
184
209
|
|
|
185
210
|
async def dshell_clear_one_reactions(ctx: Message, message, emoji):
|
|
186
211
|
"""
|
|
187
212
|
Clear one emoji on the target message
|
|
188
213
|
"""
|
|
189
|
-
if not isinstance(message, int):
|
|
190
|
-
raise Exception(f'Message must be integer, not {type(message)}')
|
|
191
214
|
|
|
192
215
|
if not isinstance(emoji, str):
|
|
193
216
|
raise Exception(f'Emoji must be string, not {type(emoji)}')
|
|
194
217
|
|
|
195
|
-
|
|
196
|
-
target_message = await ctx.channel.fetch_message(message)
|
|
197
|
-
except NotFound:
|
|
198
|
-
raise Exception(f'Message not found !')
|
|
218
|
+
target_message = ctx if message is None else utils_get_message(ctx, message)
|
|
199
219
|
|
|
200
220
|
await target_message.clear_reaction(emoji)
|
{dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/DISCORD_COMMANDS/dshell_role.py
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from discord import MISSING, Message, PermissionOverwrite
|
|
2
2
|
from discord.utils import _MissingSentinel
|
|
3
|
+
from typing import Union
|
|
3
4
|
from .._utils import NoneType
|
|
4
5
|
|
|
5
6
|
__all__ = [
|
|
@@ -56,7 +57,7 @@ async def dshell_delete_roles(ctx: Message, roles, reason=None):
|
|
|
56
57
|
Delete the role on the server
|
|
57
58
|
"""
|
|
58
59
|
from .._DshellInterpreteur.dshell_interpreter import ListNode
|
|
59
|
-
roles: int
|
|
60
|
+
roles: Union[int, ListNode]
|
|
60
61
|
if not isinstance(roles, (int, ListNode)):
|
|
61
62
|
raise Exception(f"Role must be a int, role mention or NodeList of both, not {type(roles)} !")
|
|
62
63
|
|
{dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/_DshellTokenizer/dshell_keywords.py
RENAMED
|
@@ -28,6 +28,8 @@ dshell_commands: dict[str, Callable] = {
|
|
|
28
28
|
"gp": dshell_get_pastbin, # get pastbin
|
|
29
29
|
|
|
30
30
|
"sm": dshell_send_message, # send message
|
|
31
|
+
"spm": dshell_send_private_message, # send private message
|
|
32
|
+
"srm": dshell_respond_message, # respond to a message
|
|
31
33
|
"dm": dshell_delete_message,
|
|
32
34
|
"pm": dshell_purge_message,
|
|
33
35
|
"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.9",
|
|
8
|
+
version="0.2.9.2",
|
|
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.9 → dshellinterpreter-0.2.9.2}/Dshell/DISCORD_COMMANDS/dshell_pastbin.py
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/_DshellInterpreteur/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/_DshellTokenizer/dshell_token_type.py
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/Dshell/_DshellTokenizer/dshell_tokenizer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/dshellInterpreter.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/dshellInterpreter.egg-info/requires.txt
RENAMED
|
File without changes
|
{dshellinterpreter-0.2.9 → dshellinterpreter-0.2.9.2}/dshellInterpreter.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|