dshellInterpreter 0.2.9.3__py3-none-any.whl → 0.2.10__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.

@@ -3,4 +3,4 @@ from .dshell_message import *
3
3
  from .dshell_member import *
4
4
  from .dshell_pastbin import *
5
5
  from .dshell_role import *
6
- from .utils import *
6
+ from .utils import *
File without changes
@@ -0,0 +1,28 @@
1
+ from discord import Message, PartialMessage
2
+ from typing import Union
3
+ from re import search
4
+
5
+ def utils_get_message(ctx: Message, message: Union[int, str]) -> PartialMessage:
6
+ """
7
+ Returns the message object of the specified message ID or link.
8
+ Message is only available in the same server as the command and in the same channel.
9
+ If the message is a link, it must be in the format: https://discord.com/channels/{guild_id}/{channel_id}/{message_id}
10
+ """
11
+
12
+ if isinstance(message, int):
13
+ return ctx.channel.get_partial_message(message)
14
+
15
+ elif isinstance(message, str):
16
+ match = search(r'https://discord\.com/channels/(\d+)/(\d+)/(\d+)', message)
17
+ if not match:
18
+ raise Exception("Invalid message link format. Use a valid Discord message link.")
19
+ guild_id = int(match.group(1))
20
+ channel_id = int(match.group(2))
21
+ message_id = int(match.group(3))
22
+
23
+ if guild_id != ctx.guild.id:
24
+ raise Exception("The message must be from the same server as the command !")
25
+
26
+ return ctx.guild.get_channel(channel_id).get_partial_message(message_id)
27
+
28
+ raise Exception(f"Message must be an integer or a string, not {type(message)} !")
@@ -0,0 +1,35 @@
1
+ from discord import Message, Thread
2
+ from discord.errors import NotFound
3
+
4
+ from typing import Union
5
+ from re import search
6
+
7
+
8
+ async def utils_get_thread(ctx: Message, thread: Union[int, str]) -> Thread:
9
+ """
10
+ Returns the thread object of the specified thread ID or link.
11
+ Thread is only available in the same server as the command and in the same channel.
12
+ If the thread is a link, it must be in the format: https://discord.com/channels/{guild_id}/{channel_id}/{message_id}
13
+ """
14
+
15
+ if isinstance(thread, int):
16
+ return ctx.channel.get_thread(thread)
17
+
18
+ elif isinstance(thread, str):
19
+ match = search(r'https://discord\.com/channels/(\d+)/(\d+)(/\d+)?', thread)
20
+ if not match:
21
+ raise Exception("Invalid thread link format. Use a valid Discord thread link.")
22
+ guild_id = int(match.group(1))
23
+ message_id = int(match.group(2))
24
+ channel_id = ctx.channel.id if len(match.groups()) == 3 else ctx.channel.id
25
+
26
+ if guild_id != ctx.guild.id:
27
+ raise Exception("The thread must be from the same server as the command !")
28
+
29
+ try:
30
+ c = await ctx.guild.get_channel(channel_id).fetch_message(message_id)
31
+ return c.thread
32
+ except NotFound:
33
+ raise Exception(f"Thread with ID {message_id} not found in channel {channel_id} !")
34
+
35
+ raise Exception(f"Thread must be an integer or a string, not {type(thread)} !")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.2.9.3
3
+ Version: 0.2.10
4
4
  Summary: A Discord bot interpreter for creating custom commands and automations.
5
5
  Home-page: https://github.com/BOXERRMD/Dshell_Interpreter
6
6
  Author: Chronos
@@ -1,11 +1,14 @@
1
1
  Dshell/__init__.py,sha256=pGd94FPy8kVXH_jH566HhApQPhbPfMPnZXzH_0dPWh0,93
2
2
  Dshell/_utils.py,sha256=PJ3fwn8IMqUMnW9oTwfr9v4--rzHIhhLQoVVqjwjoJU,23
3
- Dshell/DISCORD_COMMANDS/__init__.py,sha256=yQU0BPUEeGm6RuR96OSqNEBfw0B-Es51mukxSvY9KEc,171
3
+ Dshell/DISCORD_COMMANDS/__init__.py,sha256=8JPQ-6-s8PkaacmOfQgyczUiLM6rUSceHEJ60oNSis0,173
4
4
  Dshell/DISCORD_COMMANDS/dshell_channel.py,sha256=__vRngQD0USGBuJIuvHQckrtbhbufn5etaqXgNS90IA,16124
5
5
  Dshell/DISCORD_COMMANDS/dshell_member.py,sha256=5Iw-2dydhYMZOw2nx0svZP9JpZWHOXC0qkL9tClJHtw,8840
6
6
  Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=KoR5hLQiGdkmBjMUJvdItsGximA0mUJ2MmNGV_1-1b8,6942
7
7
  Dshell/DISCORD_COMMANDS/dshell_pastbin.py,sha256=TkWFGRRTvhhJgvwkDFx9Fz4UM2UUFwxyq0laMVx0mUk,881
8
8
  Dshell/DISCORD_COMMANDS/dshell_role.py,sha256=t_yRZRD0FKE2gT4dIDIsHz2PSZZztDVEkkqkG_OkNh4,5002
9
+ Dshell/DISCORD_COMMANDS/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ Dshell/DISCORD_COMMANDS/utils/utils_message.py,sha256=Pn0ljyeCvRfY4tlWHrSbIsxSFZZ5J4lDaeVme3WHp9o,1239
11
+ Dshell/DISCORD_COMMANDS/utils/utils_thread.py,sha256=tVl4msEwrWHY-0AytI6eY3JSs-eIFUigDSJfK9mT1ww,1457
9
12
  Dshell/_DshellInterpreteur/__init__.py,sha256=xy5-J-R3YmY99JF3NBHTRRLsComFxpjnCA5xacISctU,35
10
13
  Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=sYQ9qIVjRedwkfITEeVAFN0RdHjiY7RGO6z0j4D7eno,23072
11
14
  Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZxC4,56
@@ -15,8 +18,8 @@ Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8q
15
18
  Dshell/_DshellTokenizer/dshell_keywords.py,sha256=yBTXKBCb7NZa-DGDeeyIZrl_CS1Y4WCmwshUdBHQhlo,5642
16
19
  Dshell/_DshellTokenizer/dshell_token_type.py,sha256=gYIb2XN2YcgeRgmar_rBDS5CGmwfmxihu8mOW_d6lbE,1533
17
20
  Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=LZGs4Ytuyx9Galazqtz32lS4Mmu9yZya1B7AzFQAQOk,7150
18
- dshellinterpreter-0.2.9.3.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
19
- dshellinterpreter-0.2.9.3.dist-info/METADATA,sha256=gjSAX_QOCyVUbZF32EtwsgH7rCloSrA2Z6SsLItCt9w,1122
20
- dshellinterpreter-0.2.9.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
21
- dshellinterpreter-0.2.9.3.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
22
- dshellinterpreter-0.2.9.3.dist-info/RECORD,,
21
+ dshellinterpreter-0.2.10.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
22
+ dshellinterpreter-0.2.10.dist-info/METADATA,sha256=3ksf5VcfE7VEKmYXh_8CuW4i0Vql2OvgRimERoe66bw,1121
23
+ dshellinterpreter-0.2.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
+ dshellinterpreter-0.2.10.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
25
+ dshellinterpreter-0.2.10.dist-info/RECORD,,