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

@@ -14,12 +14,12 @@ __all__ = [
14
14
  'dshell_delete_message',
15
15
  'dshell_purge_message',
16
16
  'dshell_edit_message',
17
- 'dshell_get_hystory_messages',
18
- 'dshell_research_regex_in_content',
17
+ 'dshell_get_history_messages',
19
18
  'dshell_add_reactions',
20
19
  'dshell_remove_reactions',
21
20
  'dshell_clear_message_reactions',
22
- 'dshell_clear_one_reactions'
21
+ 'dshell_clear_one_reactions',
22
+ 'dshell_get_content_message'
23
23
  ]
24
24
 
25
25
 
@@ -167,7 +167,7 @@ async def dshell_edit_message(ctx: Message, message, new_content=None, embeds=No
167
167
  return edit_message.id
168
168
 
169
169
 
170
- async def dshell_get_hystory_messages(ctx: Message, channel=None, limit=None) -> "ListNode":
170
+ async def dshell_get_history_messages(ctx: Message, channel=None, limit=None) -> "ListNode":
171
171
  """
172
172
  Searches for messages matching a regex in a channel
173
173
  """
@@ -184,7 +184,7 @@ async def dshell_get_hystory_messages(ctx: Message, channel=None, limit=None) ->
184
184
 
185
185
  messages = ListNode([])
186
186
  async for message in search_channel.history(limit=limit):
187
- messages.add(message)
187
+ messages.add(message.id)
188
188
 
189
189
  if not messages:
190
190
  raise commands.CommandError(f"No messages in {search_channel.mention}.")
@@ -192,19 +192,6 @@ async def dshell_get_hystory_messages(ctx: Message, channel=None, limit=None) ->
192
192
  return messages
193
193
 
194
194
 
195
- async def dshell_research_regex_in_content(ctx: Message, regex, content=None):
196
- """
197
- Searches for a regex in a specific message content
198
- """
199
-
200
- if not isinstance(regex, str):
201
- raise Exception(f"Regex must be a string, not {type(regex)}!")
202
-
203
- if not search(regex, str(content) if content is not None else ctx.content):
204
- return False
205
-
206
- return True
207
-
208
195
 
209
196
  async def dshell_add_reactions(ctx: Message, reactions, message=None):
210
197
  """
@@ -257,3 +244,14 @@ async def dshell_clear_one_reactions(ctx: Message, message, emoji):
257
244
  target_message = ctx if message is None else utils_get_message(ctx, message)
258
245
 
259
246
  await target_message.clear_reaction(emoji)
247
+
248
+ async def dshell_get_content_message(ctx: Message, message=None):
249
+ """
250
+ Get the content of a message
251
+ """
252
+
253
+ target_message = ctx if message is None else utils_get_message(ctx, message)
254
+
255
+ return target_message.content
256
+
257
+
@@ -0,0 +1,155 @@
1
+ __all__ = [
2
+ "utils_split_string",
3
+ "utils_upper_string",
4
+ "utils_lower_string",
5
+ "utils_title_string",
6
+ "utils_strip_string",
7
+ "utils_replace_string",
8
+ "utils_regex_findall",
9
+ "utils_regex_sub",
10
+ "utils_regex_search"
11
+ ]
12
+
13
+ from discord import Message
14
+ from re import search, findall, sub
15
+
16
+ async def utils_split_string(ctx: Message, value: str, separator: str = ' ') -> "ListNode":
17
+ """
18
+ Split a string into a list of strings using the specified separator.
19
+ :param value:
20
+ :param separator:
21
+ :return:
22
+ """
23
+
24
+ if not isinstance(value, str):
25
+ raise TypeError(f"value must be a str in split command, not {type(value)}")
26
+
27
+ if not isinstance(separator, str):
28
+ raise TypeError(f"separator must be a str in split command, not {type(separator)}")
29
+
30
+ from ..._DshellParser.ast_nodes import ListNode
31
+
32
+ return ListNode(value.split(separator))
33
+
34
+ async def utils_upper_string(ctx: Message, value: str) -> str:
35
+ """
36
+ Convert a string to uppercase.
37
+ :param value:
38
+ :return:
39
+ """
40
+
41
+ if not isinstance(value, str):
42
+ raise TypeError(f"value must be a str in upper command, not {type(value)}")
43
+
44
+ return value.upper()
45
+
46
+ async def utils_lower_string(ctx: Message, value: str) -> str:
47
+ """
48
+ Convert a string to lowercase.
49
+ :param value:
50
+ :return:
51
+ """
52
+
53
+ if not isinstance(value, str):
54
+ raise TypeError(f"value must be a str in lower command, not {type(value)}")
55
+
56
+ return value.lower()
57
+
58
+ async def utils_title_string(ctx: Message, value: str) -> str:
59
+ """
60
+ Convert a string to title case.
61
+ :param value:
62
+ :return:
63
+ """
64
+
65
+ if not isinstance(value, str):
66
+ raise TypeError(f"value must be a str in title command, not {type(value)}")
67
+
68
+ return value.title()
69
+
70
+ async def utils_strip_string(ctx: Message, value: str) -> str:
71
+ """
72
+ Strip whitespace from the beginning and end of a string.
73
+ :param value:
74
+ :return:
75
+ """
76
+
77
+ if not isinstance(value, str):
78
+ raise TypeError(f"value must be a str in strip command, not {type(value)}")
79
+
80
+ return value.strip()
81
+
82
+ async def utils_replace_string(ctx: Message, value: str, old: str, new: str) -> str:
83
+ """
84
+ Replace all occurrences of old with new in a string.
85
+ :param value:
86
+ :param old:
87
+ :param new:
88
+ :return:
89
+ """
90
+
91
+ if not isinstance(value, str):
92
+ raise TypeError(f"value must be a str in replace command, not {type(value)}")
93
+
94
+ if not isinstance(old, str):
95
+ raise TypeError(f"old must be a str in replace command, not {type(old)}")
96
+
97
+ if not isinstance(new, str):
98
+ raise TypeError(f"new must be a str in replace command, not {type(new)}")
99
+
100
+ return value.replace(old, new)
101
+
102
+ async def utils_regex_findall(ctx: Message, regex: str, content: str = None) -> "ListNode":
103
+ """
104
+ Find all occurrences of a regex in a string.
105
+ :param regex:
106
+ :param content:
107
+ :return:
108
+ """
109
+
110
+ if not isinstance(regex, str):
111
+ raise Exception(f"Regex must be a string, not {type(regex)}!")
112
+
113
+ if content is not None and not isinstance(content, str):
114
+ raise Exception(f"Content must be a string, not {type(content)}!")
115
+
116
+ from ..._DshellParser.ast_nodes import ListNode
117
+
118
+ return ListNode(findall(regex, content if content is not None else ctx.content))
119
+
120
+
121
+ async def utils_regex_sub(ctx: Message, regex: str, replace: str, content: str = None) -> str:
122
+ """
123
+ Replace all occurrences of a regex in a string with a replacement string.
124
+ :param regex:
125
+ :param replace:
126
+ :param content:
127
+ :return:
128
+ """
129
+
130
+ if not isinstance(regex, str):
131
+ raise Exception(f"Regex must be a string, not {type(regex)}!")
132
+
133
+ if not isinstance(replace, str):
134
+ raise Exception(f"Replacement must be a string, not {type(replace)}!")
135
+
136
+ if content is not None and not isinstance(content, str):
137
+ raise Exception(f"Content must be a string, not {type(content)}!")
138
+
139
+ return sub(regex, replace, content if content is not None else ctx.content)
140
+
141
+ async def utils_regex_search(ctx: Message, regex: str, content: str = None) -> bool:
142
+ """
143
+ Search for a regex in a string.
144
+ :param regex:
145
+ :param content:
146
+ :return:
147
+ """
148
+
149
+ if not isinstance(regex, str):
150
+ raise Exception(f"Regex must be a string, not {type(regex)}!")
151
+
152
+ if content is not None and not isinstance(content, str):
153
+ raise Exception(f"Content must be a string, not {type(content)}!")
154
+
155
+ return bool(search(regex, content if content is not None else ctx.content))
@@ -62,6 +62,7 @@ class DshellInterpreteur:
62
62
  '__message_content__': message.content,
63
63
  '__message_id__': message.id,
64
64
  '__message_url__': message.jump_url if hasattr(message, 'jump_url') else None,
65
+ '__last_message__': message.channel.last_message_id,
65
66
 
66
67
  '__channel__': message.channel.id,
67
68
  '__channel_name__': message.channel.name,
@@ -19,6 +19,7 @@ from ..DISCORD_COMMANDS.dshell_interaction import *
19
19
  from ..DISCORD_COMMANDS.utils.utils_global import *
20
20
  from ..DISCORD_COMMANDS.utils.utils_list import *
21
21
  from ..DISCORD_COMMANDS.utils.utils_member import *
22
+ from ..DISCORD_COMMANDS.utils.utils_string import *
22
23
 
23
24
  dshell_keyword: set[str] = {
24
25
  'if', 'else', 'elif', 'loop', '#end', 'var', '#loop', '#if', 'sleep', 'param', '#param'
@@ -43,6 +44,17 @@ dshell_commands: dict[str, Callable] = {
43
44
  'reverse': utils_list_reverse,
44
45
  'get': utils_list_get_value,
45
46
 
47
+ ## String utils
48
+ 'split': utils_split_string,
49
+ 'upper': utils_upper_string,
50
+ 'lower': utils_lower_string,
51
+ 'title': utils_title_string,
52
+ 'strip': utils_strip_string,
53
+ 'replace': utils_replace_string,
54
+ 'regex_findall': utils_regex_findall,
55
+ 'regex_sub': utils_regex_sub,
56
+ 'regex': utils_regex_search,
57
+
46
58
  ## Discord utils
47
59
  'name': utils_get_name, # get the name from id (channel, role, member)
48
60
  'id': utils_get_id, # get the id from name (channel, role, member)
@@ -61,6 +73,8 @@ dshell_commands: dict[str, Callable] = {
61
73
  "dm": dshell_delete_message,
62
74
  "pm": dshell_purge_message,
63
75
  "em": dshell_edit_message, # edit message
76
+ "mh": dshell_get_history_messages, # get message history
77
+ "gcm": dshell_get_content_message, # get content of a message
64
78
 
65
79
  "sri": dshell_respond_interaction, # respond to an interaction
66
80
  "sdi": dshell_defer_interaction, # defer an interaction
@@ -90,9 +104,6 @@ dshell_commands: dict[str, Callable] = {
90
104
  "gmr": dshell_give_member_roles, # give roles
91
105
  "rmr": dshell_remove_member_roles, # remove roles
92
106
 
93
- "ghm": dshell_get_hystory_messages, # research regex in message
94
- "src": dshell_research_regex_in_content, # research regex in content
95
-
96
107
  "ec": dshell_edit_text_channel, # edit text channel
97
108
  "evc": dshell_edit_voice_channel, # edit voice channel
98
109
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dshellInterpreter
3
- Version: 0.2.17.3
3
+ Version: 0.2.18.1
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
@@ -4,7 +4,7 @@ Dshell/DISCORD_COMMANDS/__init__.py,sha256=87-YpGU74m-m7AqUQni7PGbw73JRlioQkywW_
4
4
  Dshell/DISCORD_COMMANDS/dshell_channel.py,sha256=PDXpxrRRWPSucdp_3ITJk0Ur3coneRJKWEl2i7GZ2EM,15696
5
5
  Dshell/DISCORD_COMMANDS/dshell_interaction.py,sha256=5FA8JZ2_v98ZzOZl6EKyjo_fUQC7FuK6C6hij6ZSP30,3495
6
6
  Dshell/DISCORD_COMMANDS/dshell_member.py,sha256=5Iw-2dydhYMZOw2nx0svZP9JpZWHOXC0qkL9tClJHtw,8840
7
- Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=zcWl6Y1W31h9MTHS-j9tLDwcrRiE_wGOu78zu2k0y9I,9101
7
+ Dshell/DISCORD_COMMANDS/dshell_message.py,sha256=Vzk4EsAvXNaPGTtS8t-Zvr_IwUONlafzN2EfMO6FS_0,8954
8
8
  Dshell/DISCORD_COMMANDS/dshell_pastbin.py,sha256=H0tUJOwdzYBXvxqipK3mzoNZUKrSLcVm4EZlWbBRScs,796
9
9
  Dshell/DISCORD_COMMANDS/dshell_role.py,sha256=t_yRZRD0FKE2gT4dIDIsHz2PSZZztDVEkkqkG_OkNh4,5002
10
10
  Dshell/DISCORD_COMMANDS/utils/__init__.py,sha256=-amNcYysjgx3YDpDSnbQmJhnm3lbJere9K9aDH-YnJg,115
@@ -13,19 +13,20 @@ Dshell/DISCORD_COMMANDS/utils/utils_list.py,sha256=zqImMWvD-1UnbPP1TZewnvZpq7qs1
13
13
  Dshell/DISCORD_COMMANDS/utils/utils_member.py,sha256=1EoHooxwijc7AFJGnuae3ccjQk0x69MELtZ5ES5abLY,1165
14
14
  Dshell/DISCORD_COMMANDS/utils/utils_message.py,sha256=cQvJ15f49ddOjybARwkJKNFe3ITYQciF-pZHERFPkr0,2964
15
15
  Dshell/DISCORD_COMMANDS/utils/utils_permissions.py,sha256=Gi6vpCA2yXUZ20OCay5dkX6HeN4LglVROwcvTWVCsKg,3600
16
+ Dshell/DISCORD_COMMANDS/utils/utils_string.py,sha256=WyTJJXjHwxs_76PKclRErjK8b6CFYpZhbZbAlr259HA,4667
16
17
  Dshell/DISCORD_COMMANDS/utils/utils_thread.py,sha256=tVl4msEwrWHY-0AytI6eY3JSs-eIFUigDSJfK9mT1ww,1457
17
18
  Dshell/_DshellInterpreteur/__init__.py,sha256=jl_gH8MoqerW--I-IHXwUZTo80JOtfr7AOA57xVgeGQ,58
18
- Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=PcwfNPz44v6gsl-xNcvNwV5lcLhpJ6yDdjwHHnE6OUE,29493
19
+ Dshell/_DshellInterpreteur/dshell_interpreter.py,sha256=wX7P7MwJ0O6I5mZ5FJG7qoH8qfObGuxPUVjerhRPYtM,29559
19
20
  Dshell/_DshellInterpreteur/errors.py,sha256=0PJz_VYZfNZeKR_PEHxw3tRkgKNNUerV0wwrq2r1luA,250
20
21
  Dshell/_DshellParser/__init__.py,sha256=ONDfhZMvClqP_6tE8SLjp-cf3pXL-auQYnfYRrHZxC4,56
21
22
  Dshell/_DshellParser/ast_nodes.py,sha256=RLlylX9bvbJEG3BDMGS4mnMxU8ufnZYIF59NVf_pW7A,18883
22
23
  Dshell/_DshellParser/dshell_parser.py,sha256=cpukpWFJlioP1pIZZMGg24GrXfnnz1nuPCIKRNsxAcE,18949
23
24
  Dshell/_DshellTokenizer/__init__.py,sha256=LIQSRhDx2B9pmPx5ADMwwD0Xr9ybneVLhHH8qrJWw_s,172
24
- Dshell/_DshellTokenizer/dshell_keywords.py,sha256=MUTt4NCHzu2gqBgCS1fS0ULHR5K0crCMajE7WiglcJY,6839
25
+ Dshell/_DshellTokenizer/dshell_keywords.py,sha256=TI5O6y6gAXpM_dKxCW9Fk0H8VR-gmyxxKKOURgcHsCg,7219
25
26
  Dshell/_DshellTokenizer/dshell_token_type.py,sha256=gYIb2XN2YcgeRgmar_rBDS5CGmwfmxihu8mOW_d6lbE,1533
26
27
  Dshell/_DshellTokenizer/dshell_tokenizer.py,sha256=AJnUocD6hbU6wvjRAN5uDha5QQieTwXlHzZVtgRGaZQ,7307
27
- dshellinterpreter-0.2.17.3.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
28
- dshellinterpreter-0.2.17.3.dist-info/METADATA,sha256=U-vTg98gsSZvkSaMyO5GA6vsCyg4_n7DYCE3l8QZOuo,1151
29
- dshellinterpreter-0.2.17.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
- dshellinterpreter-0.2.17.3.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
31
- dshellinterpreter-0.2.17.3.dist-info/RECORD,,
28
+ dshellinterpreter-0.2.18.1.dist-info/licenses/LICENSE,sha256=lNgcw1_xb7QENAQi3uHGymaFtbs0RV-ihiCd7AoLQjA,1082
29
+ dshellinterpreter-0.2.18.1.dist-info/METADATA,sha256=2G017CKReQAhq-2HowFAt1jg9yPxNVWhl5iF-25OCco,1151
30
+ dshellinterpreter-0.2.18.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
+ dshellinterpreter-0.2.18.1.dist-info/top_level.txt,sha256=B4CMhtmchGwPQJLuqUy0GhRG-0cUGxKL4GqEbCiB_vE,7
32
+ dshellinterpreter-0.2.18.1.dist-info/RECORD,,