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

@@ -4,11 +4,22 @@ __all__ = [
4
4
  ]
5
5
 
6
6
  from types import NoneType
7
- from discord import Interaction, Embed
7
+ from discord import Interaction, Embed, AllowedMentions
8
8
  from pycordViews import EasyModifiedViews
9
9
 
10
-
11
- async def dshell_respond_interaction(ctx: Interaction, content: str = None, delete=None, mentions: bool = None, hide: bool = False, embeds=None, view=None) -> int:
10
+ from .utils.utils_message import utils_autorised_mentions
11
+
12
+ async def dshell_respond_interaction(ctx: Interaction,
13
+ content: str = None,
14
+ delete=None,
15
+ global_mentions: bool = None,
16
+ everyone_mention: bool = True,
17
+ roles_mentions: bool = True,
18
+ users_mentions: bool = True,
19
+ reply_mention: bool = False,
20
+ hide: bool = False,
21
+ embeds=None,
22
+ view=None) -> int:
12
23
  """
13
24
  Responds to a message interaction on Discord
14
25
  """
@@ -19,13 +30,14 @@ async def dshell_respond_interaction(ctx: Interaction, content: str = None, dele
19
30
  if delete is not None and not isinstance(delete, (int, float)):
20
31
  raise Exception(f'Delete parameter must be a number (seconds) or None, not {type(delete)} !')
21
32
 
22
- if not isinstance(mentions, (NoneType, bool)):
23
- raise Exception(f'Mention parameter must be a boolean or None, not {type(mentions)} !')
24
-
25
33
  if not isinstance(hide, bool):
26
34
  raise Exception(f'Hide parameter must be a boolean, not {type(hide)} !')
27
35
 
28
- allowed_mentions = mentions if mentions is not None else False
36
+ allowed_mentions = utils_autorised_mentions(global_mentions,
37
+ everyone_mention,
38
+ roles_mentions,
39
+ users_mentions,
40
+ reply_mention)
29
41
 
30
42
  from .._DshellParser.ast_nodes import ListNode
31
43
 
@@ -1,12 +1,11 @@
1
1
  from re import search
2
- from tkinter import Listbox
3
2
 
4
- from discord import Embed, Message, Interaction
3
+ from discord import Embed, Message
5
4
  from discord.ext import commands
6
5
 
7
6
  from pycordViews import EasyModifiedViews
8
7
 
9
- from .utils.utils_message import utils_get_message
8
+ from .utils.utils_message import utils_get_message, utils_autorised_mentions
10
9
  from .._utils import NoneType
11
10
 
12
11
  __all__ = [
@@ -24,7 +23,17 @@ __all__ = [
24
23
  ]
25
24
 
26
25
 
27
- async def dshell_send_message(ctx: Message, message=None, delete=None, channel=None, embeds=None, view=None) -> int:
26
+ async def dshell_send_message(ctx: Message,
27
+ message=None,
28
+ delete=None,
29
+ channel=None,
30
+ global_mentions: bool = None,
31
+ everyone_mention: bool = True,
32
+ roles_mentions: bool = True,
33
+ users_mentions: bool = True,
34
+ reply_mention: bool = False,
35
+ embeds=None,
36
+ view=None) -> int:
28
37
  """
29
38
  Sends a message on Discord
30
39
  """
@@ -33,6 +42,7 @@ async def dshell_send_message(ctx: Message, message=None, delete=None, channel=N
33
42
  raise Exception(f'Delete parameter must be a number (seconds) or None, not {type(delete)} !')
34
43
 
35
44
  channel_to_send = ctx.channel if channel is None else ctx.channel.guild.get_channel(channel)
45
+ allowed_mentions = utils_autorised_mentions(global_mentions, everyone_mention, roles_mentions, users_mentions, reply_mention)
36
46
 
37
47
  if channel_to_send is None:
38
48
  raise Exception(f'Channel {channel} not found!')
@@ -54,12 +64,22 @@ async def dshell_send_message(ctx: Message, message=None, delete=None, channel=N
54
64
  sended_message = await channel_to_send.send(message,
55
65
  delete_after=delete,
56
66
  embeds=embeds,
67
+ allowed_mentions=allowed_mentions,
57
68
  view=view)
58
69
 
59
70
  return sended_message.id
60
71
 
61
72
 
62
- async def dshell_respond_message(ctx: Message, message=None, content: str = None, delete=None, mention: bool = None, embeds=None):
73
+ async def dshell_respond_message(ctx: Message,
74
+ message=None,
75
+ content: str = None,
76
+ global_mentions: bool = None,
77
+ everyone_mention: bool = True,
78
+ roles_mentions: bool = True,
79
+ users_mentions: bool = True,
80
+ reply_mention: bool = False,
81
+ delete=None,
82
+ embeds=None):
63
83
  """
64
84
  Responds to a message on Discord
65
85
  """
@@ -67,7 +87,8 @@ async def dshell_respond_message(ctx: Message, message=None, content: str = None
67
87
  raise Exception(f'Delete parameter must be a number (seconds) or None, not {type(delete)} !')
68
88
 
69
89
  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)
70
- mention_author = mention if mention is not None else False
90
+ autorised_mentions = utils_autorised_mentions(global_mentions, everyone_mention, roles_mentions, users_mentions, reply_mention)
91
+ mention_author = True if reply_mention else False
71
92
 
72
93
  from .._DshellParser.ast_nodes import ListNode
73
94
 
@@ -83,6 +104,7 @@ async def dshell_respond_message(ctx: Message, message=None, content: str = None
83
104
  sended_message = await respond_message.reply(
84
105
  content=str(content),
85
106
  mention_author=mention_author,
107
+ allowed_mentions=autorised_mentions,
86
108
  delete_after=delete,
87
109
  embeds=embeds)
88
110
 
@@ -1,4 +1,4 @@
1
- from discord import Message, PartialMessage
1
+ from discord import Message, PartialMessage, AllowedMentions
2
2
  from typing import Union
3
3
  from re import search
4
4
 
@@ -26,3 +26,43 @@ def utils_get_message(ctx: Message, message: Union[int, str]) -> PartialMessage:
26
26
  return ctx.guild.get_channel(channel_id).get_partial_message(message_id)
27
27
 
28
28
  raise Exception(f"Message must be an integer or a string, not {type(message)} !")
29
+
30
+
31
+ def utils_autorised_mentions(global_mentions: bool = None,
32
+ everyone_mention: bool = True,
33
+ roles_mentions: bool = True,
34
+ users_mentions: bool = True,
35
+ reply_mention: bool = False) -> Union[bool, 'AllowedMentions']:
36
+ """
37
+ Returns the AllowedMentions object based on the provided parameters.
38
+ If global_mentions is set to True or False, it overrides all other parameters.
39
+ """
40
+
41
+ from discord import AllowedMentions
42
+
43
+ if not isinstance(global_mentions, (type(None), bool)):
44
+ raise Exception(f'Mention parameter must be a boolean or None, not {type(global_mentions)} !')
45
+
46
+ if not isinstance(everyone_mention, bool):
47
+ raise Exception(f'Everyone mention parameter must be a boolean, not {type(everyone_mention)} !')
48
+
49
+ if not isinstance(roles_mentions, bool):
50
+ raise Exception(f'Roles mention parameter must be a boolean, not {type(roles_mentions)} !')
51
+
52
+ if not isinstance(users_mentions, bool):
53
+ raise Exception(f'Users mention parameter must be a boolean, not {type(users_mentions)} !')
54
+
55
+ if not isinstance(reply_mention, bool):
56
+ raise Exception(f'Reply mention parameter must be a boolean, not {type(reply_mention)} !')
57
+
58
+ if global_mentions is True:
59
+ return AllowedMentions.all()
60
+
61
+ elif global_mentions is False:
62
+ return AllowedMentions.none()
63
+
64
+ else:
65
+ return AllowedMentions(everyone=everyone_mention,
66
+ roles=roles_mentions,
67
+ users=users_mentions,
68
+ replied_user=reply_mention)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.2.13.14
3
+ Version: 0.2.13.15
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
@@ -2,13 +2,13 @@ Dshell/__init__.py,sha256=pGd94FPy8kVXH_jH566HhApQPhbPfMPnZXzH_0dPWh0,93
2
2
  Dshell/_utils.py,sha256=PJ3fwn8IMqUMnW9oTwfr9v4--rzHIhhLQoVVqjwjoJU,23
3
3
  Dshell/DISCORD_COMMANDS/__init__.py,sha256=87-YpGU74m-m7AqUQni7PGbw73JRlioQkywW_61Whms,208
4
4
  Dshell/DISCORD_COMMANDS/dshell_channel.py,sha256=qpNe3oE5VyLCmOeCjWlt0rvaSBv2yrkmJgrRswrNOZM,15721
5
- Dshell/DISCORD_COMMANDS/dshell_interaction.py,sha256=f1DsMeMcI8t_54x-a9mW2pF5RSxNV0hf0ZV-Dt7p_qk,2540
5
+ Dshell/DISCORD_COMMANDS/dshell_interaction.py,sha256=Gac3J9sCcPRHApIgSoS5MRAMJ0Hd7I-YywVQI0s26p0,3229
6
6
  Dshell/DISCORD_COMMANDS/dshell_member.py,sha256=5Iw-2dydhYMZOw2nx0svZP9JpZWHOXC0qkL9tClJHtw,8840
7
- Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=VsZk-scVn-OgIKNYFCtWnAf5WowG2ODTa_pNG2ZEZgI,7813
7
+ Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=zcWl6Y1W31h9MTHS-j9tLDwcrRiE_wGOu78zu2k0y9I,9101
8
8
  Dshell/DISCORD_COMMANDS/dshell_pastbin.py,sha256=TkWFGRRTvhhJgvwkDFx9Fz4UM2UUFwxyq0laMVx0mUk,881
9
9
  Dshell/DISCORD_COMMANDS/dshell_role.py,sha256=t_yRZRD0FKE2gT4dIDIsHz2PSZZztDVEkkqkG_OkNh4,5002
10
10
  Dshell/DISCORD_COMMANDS/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- Dshell/DISCORD_COMMANDS/utils/utils_message.py,sha256=Pn0ljyeCvRfY4tlWHrSbIsxSFZZ5J4lDaeVme3WHp9o,1239
11
+ Dshell/DISCORD_COMMANDS/utils/utils_message.py,sha256=cQvJ15f49ddOjybARwkJKNFe3ITYQciF-pZHERFPkr0,2964
12
12
  Dshell/DISCORD_COMMANDS/utils/utils_thread.py,sha256=tVl4msEwrWHY-0AytI6eY3JSs-eIFUigDSJfK9mT1ww,1457
13
13
  Dshell/_DshellInterpreteur/__init__.py,sha256=xy5-J-R3YmY99JF3NBHTRRLsComFxpjnCA5xacISctU,35
14
14
  Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=ukWRqOYU9pmflnlxF8tgOuuU5I0dSXf5t95R4D2AJtc,27650
@@ -19,8 +19,8 @@ Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8q
19
19
  Dshell/_DshellTokenizer/dshell_keywords.py,sha256=FY9iByZkNSI4r2M6LCDjjx65awZ_iQyFeOvjYmeK-6A,5860
20
20
  Dshell/_DshellTokenizer/dshell_token_type.py,sha256=gYIb2XN2YcgeRgmar_rBDS5CGmwfmxihu8mOW_d6lbE,1533
21
21
  Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=RrJA2XpcFH2vS6SnRIn5Own_uL5orIDvpq74t8xD3og,7350
22
- dshellinterpreter-0.2.13.14.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
23
- dshellinterpreter-0.2.13.14.dist-info/METADATA,sha256=8e63xZyweFZwrMI-n2DduWjtScIDHp_WelngI3zoD-A,1152
24
- dshellinterpreter-0.2.13.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
- dshellinterpreter-0.2.13.14.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
26
- dshellinterpreter-0.2.13.14.dist-info/RECORD,,
22
+ dshellinterpreter-0.2.13.15.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
23
+ dshellinterpreter-0.2.13.15.dist-info/METADATA,sha256=ly2oZrfOh1aGwRLfDgpQQRry_UBjK7l3EUa1SbTzgyc,1152
24
+ dshellinterpreter-0.2.13.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
+ dshellinterpreter-0.2.13.15.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
26
+ dshellinterpreter-0.2.13.15.dist-info/RECORD,,