dshellInterpreter 0.2.9.3__tar.gz → 0.2.10__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.

Files changed (30) hide show
  1. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/DISCORD_COMMANDS/__init__.py +1 -1
  2. dshellinterpreter-0.2.10/Dshell/DISCORD_COMMANDS/utils/__init__.py +0 -0
  3. dshellinterpreter-0.2.10/Dshell/DISCORD_COMMANDS/utils/utils_message.py +28 -0
  4. dshellinterpreter-0.2.10/Dshell/DISCORD_COMMANDS/utils/utils_thread.py +35 -0
  5. {dshellinterpreter-0.2.9.3/dshellInterpreter.egg-info → dshellinterpreter-0.2.10}/PKG-INFO +1 -1
  6. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10/dshellInterpreter.egg-info}/PKG-INFO +1 -1
  7. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/dshellInterpreter.egg-info/SOURCES.txt +3 -0
  8. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/setup.py +7 -3
  9. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/DISCORD_COMMANDS/dshell_channel.py +0 -0
  10. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/DISCORD_COMMANDS/dshell_member.py +0 -0
  11. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/DISCORD_COMMANDS/dshell_message.py +0 -0
  12. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/DISCORD_COMMANDS/dshell_pastbin.py +0 -0
  13. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/DISCORD_COMMANDS/dshell_role.py +0 -0
  14. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/_DshellInterpreteur/__init__.py +0 -0
  15. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/_DshellInterpreteur/dshell_interpreter.py +0 -0
  16. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/_DshellParser/__init__.py +0 -0
  17. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/_DshellParser/ast_nodes.py +0 -0
  18. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/_DshellParser/dshell_parser.py +0 -0
  19. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/_DshellTokenizer/__init__.py +0 -0
  20. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/_DshellTokenizer/dshell_keywords.py +0 -0
  21. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/_DshellTokenizer/dshell_token_type.py +0 -0
  22. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/_DshellTokenizer/dshell_tokenizer.py +0 -0
  23. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/__init__.py +0 -0
  24. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/Dshell/_utils.py +0 -0
  25. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/LICENSE +0 -0
  26. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/README.md +0 -0
  27. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/dshellInterpreter.egg-info/dependency_links.txt +0 -0
  28. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/dshellInterpreter.egg-info/requires.txt +0 -0
  29. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/dshellInterpreter.egg-info/top_level.txt +0 -0
  30. {dshellinterpreter-0.2.9.3 → dshellinterpreter-0.2.10}/setup.cfg +0 -0
@@ -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 *
@@ -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,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
@@ -9,6 +9,9 @@ Dshell/DISCORD_COMMANDS/dshell_member.py
9
9
  Dshell/DISCORD_COMMANDS/dshell_message.py
10
10
  Dshell/DISCORD_COMMANDS/dshell_pastbin.py
11
11
  Dshell/DISCORD_COMMANDS/dshell_role.py
12
+ Dshell/DISCORD_COMMANDS/utils/__init__.py
13
+ Dshell/DISCORD_COMMANDS/utils/utils_message.py
14
+ Dshell/DISCORD_COMMANDS/utils/utils_thread.py
12
15
  Dshell/_DshellInterpreteur/__init__.py
13
16
  Dshell/_DshellInterpreteur/dshell_interpreter.py
14
17
  Dshell/_DshellParser/__init__.py
@@ -5,15 +5,19 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setup(
7
7
  name="dshellInterpreter",
8
- version="0.2.9.3",
8
+ version="0.2.10",
9
9
  author="Chronos",
10
10
  author_email="vagabonwalybi@gmail.com",
11
11
  description="A Discord bot interpreter for creating custom commands and automations.",
12
12
  long_description=long_description,
13
13
  long_description_content_type="text/markdown",
14
14
  url="https://github.com/BOXERRMD/Dshell_Interpreter",
15
- packages=["Dshell", "Dshell._DshellInterpreteur", "Dshell._DshellTokenizer", "Dshell._DshellParser",
16
- "Dshell.DISCORD_COMMANDS"],
15
+ packages=["Dshell",
16
+ "Dshell._DshellInterpreteur",
17
+ "Dshell._DshellTokenizer",
18
+ "Dshell._DshellParser",
19
+ "Dshell.DISCORD_COMMANDS",
20
+ "Dshell.DISCORD_COMMANDS.utils"],
17
21
  install_requires=["py-cord==2.6.1", "requests"],
18
22
  classifiers=[
19
23
  "Programming Language :: Python :: 3",